Readable unit test - lists of complex objects











up vote
3
down vote

favorite












Goal: Writing more readable tests.



I have a couple of functions, which basically merge and converts two lists of Datasets together, written using Scala and Spark. Each of these Datasets has a lot of fields inside it. For testing, I'm creating three Datasets: New records, existing records, and expected result.



The problem is, tests are long and hard to read. An example:



test("Merging Movies") {

val newMovies: Dataset[ATMMovie] = Seq(
ATMMovie(
id = 123L,
utc_insert_timestamp = Some(1524522274),
movie_title = Some("New movie from ATM"),
censor_rating_id = Some(0),
release_year = Some(2018),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
internal_pos_movie_code = Some("P1"),
internal_pos_movie_id = Some("ID1"),
temporary = 0,
utc_last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 0
),
ATMMovie(
id = 456L,
utc_insert_timestamp = Some(34567522274L),
movie_title = Some("Title updated"),
censor_rating_id = Some(0),
release_year = Some(2016),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
internal_pos_movie_code = Some("Movie2"),
internal_pos_movie_id = Some("MovieID2"),
temporary = 0,
utc_last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 3
)
).toDS

val existingMovies: Dataset[ODSMovie] = Seq(
ODSMovie(
movie_row_id = 2L,
movie_source_id = Some("234"),
movie_entity_id = 7777L,
utc_insert_timestamp = Some(1524522000),
movie_title = Some("Old ODS Movie"),
censor_rating_id = Some(0),
release_year = Some(2017),
release_date = Some(1524522987),
primary_language_id = Some(1),
distributor_id = Some(5),
internal_pos_movie_id = Some("Movie 1"),
temporary = 0,
utc_Last_modified_timestamp = Some(1524522666),
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 1
),
ODSMovie(
movie_row_id = 764L,
movie_entity_id = 658L,
utc_insert_timestamp = Some(94567522333L),
movie_title = Some("Old title"),
censor_rating_id = Some(0),
release_year = Some(2016),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
movie_source_id = Some("Movie2"),
internal_pos_movie_id = Some("MovieID2-old"),
temporary = 0,
utc_Last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 0
)
).toDS

val expectedODSMovies: Dataset[ODSMovie] = Seq(
ODSMovie(
movie_row_id = 765L,
movie_source_id = Some("P1"),
movie_entity_id = 123L,
utc_insert_timestamp = Some(1524522274),
movie_title = Some("New movie from ATM"),
censor_rating_id = Some(0),
release_year = Some(2018),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
internal_pos_movie_id = Some("ID1"),
temporary = 0,
utc_Last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 0
),
ODSMovie(
movie_row_id = 764L,
movie_entity_id = 456L,
utc_insert_timestamp = Some(34567522274L),
movie_title = Some("Title updated"),
censor_rating_id = Some(0),
release_year = Some(2016),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
movie_source_id = Some("Movie2"),
internal_pos_movie_id = Some("MovieID2"),
temporary = 0,
utc_Last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 3
),
ODSMovie( // Movie we had.
movie_row_id = 2L,
movie_source_id = Some("234"),
movie_entity_id = 7777L,
utc_insert_timestamp = Some(1524522000),
movie_title = Some("Old ODS Movie"),
censor_rating_id = Some(0),
release_year = Some(2017),
release_date = Some(1524522987),
primary_language_id = Some(1),
distributor_id = Some(5),
internal_pos_movie_id = Some("Movie 1"),
temporary = 0,
utc_Last_modified_timestamp = Some(1524522666),
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 1
)
).toDS


As you see, each test is very hard to read and follow. I'm looking to find a better way to write these tests.



Update: I don't care about the value of most of the fields. I'm going to test the logic of merging.










share|improve this question
















bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • I don't know about Scala syntax, but have you considered migrating data to JSON and parse it from the code instead of having it everything in the code?
    – Xtreme Biker
    May 3 at 6:31












  • Without seeing the code that performs this "merging" I find it hard to tell what's going on in here. Without understanding what are you testing, it's hard to suggest improvements for the tests.
    – Rene Saarsoo
    May 3 at 12:25






  • 1




    My team and I typically find that having a "defaults" file in our API test package to be very useful when writing data-oriented tests. If these domain objects need to be used in future, we can rely on the fact that they're determinstic and centralized.
    – erip
    May 11 at 11:42















up vote
3
down vote

favorite












Goal: Writing more readable tests.



I have a couple of functions, which basically merge and converts two lists of Datasets together, written using Scala and Spark. Each of these Datasets has a lot of fields inside it. For testing, I'm creating three Datasets: New records, existing records, and expected result.



The problem is, tests are long and hard to read. An example:



test("Merging Movies") {

val newMovies: Dataset[ATMMovie] = Seq(
ATMMovie(
id = 123L,
utc_insert_timestamp = Some(1524522274),
movie_title = Some("New movie from ATM"),
censor_rating_id = Some(0),
release_year = Some(2018),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
internal_pos_movie_code = Some("P1"),
internal_pos_movie_id = Some("ID1"),
temporary = 0,
utc_last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 0
),
ATMMovie(
id = 456L,
utc_insert_timestamp = Some(34567522274L),
movie_title = Some("Title updated"),
censor_rating_id = Some(0),
release_year = Some(2016),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
internal_pos_movie_code = Some("Movie2"),
internal_pos_movie_id = Some("MovieID2"),
temporary = 0,
utc_last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 3
)
).toDS

val existingMovies: Dataset[ODSMovie] = Seq(
ODSMovie(
movie_row_id = 2L,
movie_source_id = Some("234"),
movie_entity_id = 7777L,
utc_insert_timestamp = Some(1524522000),
movie_title = Some("Old ODS Movie"),
censor_rating_id = Some(0),
release_year = Some(2017),
release_date = Some(1524522987),
primary_language_id = Some(1),
distributor_id = Some(5),
internal_pos_movie_id = Some("Movie 1"),
temporary = 0,
utc_Last_modified_timestamp = Some(1524522666),
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 1
),
ODSMovie(
movie_row_id = 764L,
movie_entity_id = 658L,
utc_insert_timestamp = Some(94567522333L),
movie_title = Some("Old title"),
censor_rating_id = Some(0),
release_year = Some(2016),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
movie_source_id = Some("Movie2"),
internal_pos_movie_id = Some("MovieID2-old"),
temporary = 0,
utc_Last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 0
)
).toDS

val expectedODSMovies: Dataset[ODSMovie] = Seq(
ODSMovie(
movie_row_id = 765L,
movie_source_id = Some("P1"),
movie_entity_id = 123L,
utc_insert_timestamp = Some(1524522274),
movie_title = Some("New movie from ATM"),
censor_rating_id = Some(0),
release_year = Some(2018),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
internal_pos_movie_id = Some("ID1"),
temporary = 0,
utc_Last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 0
),
ODSMovie(
movie_row_id = 764L,
movie_entity_id = 456L,
utc_insert_timestamp = Some(34567522274L),
movie_title = Some("Title updated"),
censor_rating_id = Some(0),
release_year = Some(2016),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
movie_source_id = Some("Movie2"),
internal_pos_movie_id = Some("MovieID2"),
temporary = 0,
utc_Last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 3
),
ODSMovie( // Movie we had.
movie_row_id = 2L,
movie_source_id = Some("234"),
movie_entity_id = 7777L,
utc_insert_timestamp = Some(1524522000),
movie_title = Some("Old ODS Movie"),
censor_rating_id = Some(0),
release_year = Some(2017),
release_date = Some(1524522987),
primary_language_id = Some(1),
distributor_id = Some(5),
internal_pos_movie_id = Some("Movie 1"),
temporary = 0,
utc_Last_modified_timestamp = Some(1524522666),
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 1
)
).toDS


As you see, each test is very hard to read and follow. I'm looking to find a better way to write these tests.



Update: I don't care about the value of most of the fields. I'm going to test the logic of merging.










share|improve this question
















bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • I don't know about Scala syntax, but have you considered migrating data to JSON and parse it from the code instead of having it everything in the code?
    – Xtreme Biker
    May 3 at 6:31












  • Without seeing the code that performs this "merging" I find it hard to tell what's going on in here. Without understanding what are you testing, it's hard to suggest improvements for the tests.
    – Rene Saarsoo
    May 3 at 12:25






  • 1




    My team and I typically find that having a "defaults" file in our API test package to be very useful when writing data-oriented tests. If these domain objects need to be used in future, we can rely on the fact that they're determinstic and centralized.
    – erip
    May 11 at 11:42













up vote
3
down vote

favorite









up vote
3
down vote

favorite











Goal: Writing more readable tests.



I have a couple of functions, which basically merge and converts two lists of Datasets together, written using Scala and Spark. Each of these Datasets has a lot of fields inside it. For testing, I'm creating three Datasets: New records, existing records, and expected result.



The problem is, tests are long and hard to read. An example:



test("Merging Movies") {

val newMovies: Dataset[ATMMovie] = Seq(
ATMMovie(
id = 123L,
utc_insert_timestamp = Some(1524522274),
movie_title = Some("New movie from ATM"),
censor_rating_id = Some(0),
release_year = Some(2018),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
internal_pos_movie_code = Some("P1"),
internal_pos_movie_id = Some("ID1"),
temporary = 0,
utc_last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 0
),
ATMMovie(
id = 456L,
utc_insert_timestamp = Some(34567522274L),
movie_title = Some("Title updated"),
censor_rating_id = Some(0),
release_year = Some(2016),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
internal_pos_movie_code = Some("Movie2"),
internal_pos_movie_id = Some("MovieID2"),
temporary = 0,
utc_last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 3
)
).toDS

val existingMovies: Dataset[ODSMovie] = Seq(
ODSMovie(
movie_row_id = 2L,
movie_source_id = Some("234"),
movie_entity_id = 7777L,
utc_insert_timestamp = Some(1524522000),
movie_title = Some("Old ODS Movie"),
censor_rating_id = Some(0),
release_year = Some(2017),
release_date = Some(1524522987),
primary_language_id = Some(1),
distributor_id = Some(5),
internal_pos_movie_id = Some("Movie 1"),
temporary = 0,
utc_Last_modified_timestamp = Some(1524522666),
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 1
),
ODSMovie(
movie_row_id = 764L,
movie_entity_id = 658L,
utc_insert_timestamp = Some(94567522333L),
movie_title = Some("Old title"),
censor_rating_id = Some(0),
release_year = Some(2016),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
movie_source_id = Some("Movie2"),
internal_pos_movie_id = Some("MovieID2-old"),
temporary = 0,
utc_Last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 0
)
).toDS

val expectedODSMovies: Dataset[ODSMovie] = Seq(
ODSMovie(
movie_row_id = 765L,
movie_source_id = Some("P1"),
movie_entity_id = 123L,
utc_insert_timestamp = Some(1524522274),
movie_title = Some("New movie from ATM"),
censor_rating_id = Some(0),
release_year = Some(2018),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
internal_pos_movie_id = Some("ID1"),
temporary = 0,
utc_Last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 0
),
ODSMovie(
movie_row_id = 764L,
movie_entity_id = 456L,
utc_insert_timestamp = Some(34567522274L),
movie_title = Some("Title updated"),
censor_rating_id = Some(0),
release_year = Some(2016),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
movie_source_id = Some("Movie2"),
internal_pos_movie_id = Some("MovieID2"),
temporary = 0,
utc_Last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 3
),
ODSMovie( // Movie we had.
movie_row_id = 2L,
movie_source_id = Some("234"),
movie_entity_id = 7777L,
utc_insert_timestamp = Some(1524522000),
movie_title = Some("Old ODS Movie"),
censor_rating_id = Some(0),
release_year = Some(2017),
release_date = Some(1524522987),
primary_language_id = Some(1),
distributor_id = Some(5),
internal_pos_movie_id = Some("Movie 1"),
temporary = 0,
utc_Last_modified_timestamp = Some(1524522666),
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 1
)
).toDS


As you see, each test is very hard to read and follow. I'm looking to find a better way to write these tests.



Update: I don't care about the value of most of the fields. I'm going to test the logic of merging.










share|improve this question















Goal: Writing more readable tests.



I have a couple of functions, which basically merge and converts two lists of Datasets together, written using Scala and Spark. Each of these Datasets has a lot of fields inside it. For testing, I'm creating three Datasets: New records, existing records, and expected result.



The problem is, tests are long and hard to read. An example:



test("Merging Movies") {

val newMovies: Dataset[ATMMovie] = Seq(
ATMMovie(
id = 123L,
utc_insert_timestamp = Some(1524522274),
movie_title = Some("New movie from ATM"),
censor_rating_id = Some(0),
release_year = Some(2018),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
internal_pos_movie_code = Some("P1"),
internal_pos_movie_id = Some("ID1"),
temporary = 0,
utc_last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 0
),
ATMMovie(
id = 456L,
utc_insert_timestamp = Some(34567522274L),
movie_title = Some("Title updated"),
censor_rating_id = Some(0),
release_year = Some(2016),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
internal_pos_movie_code = Some("Movie2"),
internal_pos_movie_id = Some("MovieID2"),
temporary = 0,
utc_last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 3
)
).toDS

val existingMovies: Dataset[ODSMovie] = Seq(
ODSMovie(
movie_row_id = 2L,
movie_source_id = Some("234"),
movie_entity_id = 7777L,
utc_insert_timestamp = Some(1524522000),
movie_title = Some("Old ODS Movie"),
censor_rating_id = Some(0),
release_year = Some(2017),
release_date = Some(1524522987),
primary_language_id = Some(1),
distributor_id = Some(5),
internal_pos_movie_id = Some("Movie 1"),
temporary = 0,
utc_Last_modified_timestamp = Some(1524522666),
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 1
),
ODSMovie(
movie_row_id = 764L,
movie_entity_id = 658L,
utc_insert_timestamp = Some(94567522333L),
movie_title = Some("Old title"),
censor_rating_id = Some(0),
release_year = Some(2016),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
movie_source_id = Some("Movie2"),
internal_pos_movie_id = Some("MovieID2-old"),
temporary = 0,
utc_Last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 0
)
).toDS

val expectedODSMovies: Dataset[ODSMovie] = Seq(
ODSMovie(
movie_row_id = 765L,
movie_source_id = Some("P1"),
movie_entity_id = 123L,
utc_insert_timestamp = Some(1524522274),
movie_title = Some("New movie from ATM"),
censor_rating_id = Some(0),
release_year = Some(2018),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
internal_pos_movie_id = Some("ID1"),
temporary = 0,
utc_Last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 0
),
ODSMovie(
movie_row_id = 764L,
movie_entity_id = 456L,
utc_insert_timestamp = Some(34567522274L),
movie_title = Some("Title updated"),
censor_rating_id = Some(0),
release_year = Some(2016),
release_date = Some(1524522000),
primary_language_id = Some(0),
distributor_id = Some(0),
movie_source_id = Some("Movie2"),
internal_pos_movie_id = Some("MovieID2"),
temporary = 0,
utc_Last_modified_timestamp = None,
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 3
),
ODSMovie( // Movie we had.
movie_row_id = 2L,
movie_source_id = Some("234"),
movie_entity_id = 7777L,
utc_insert_timestamp = Some(1524522000),
movie_title = Some("Old ODS Movie"),
censor_rating_id = Some(0),
release_year = Some(2017),
release_date = Some(1524522987),
primary_language_id = Some(1),
distributor_id = Some(5),
internal_pos_movie_id = Some("Movie 1"),
temporary = 0,
utc_Last_modified_timestamp = Some(1524522666),
force_update = 0,
utc_last_import_attempt_timestamp = None,
import_attempts = 1
)
).toDS


As you see, each test is very hard to read and follow. I'm looking to find a better way to write these tests.



Update: I don't care about the value of most of the fields. I'm going to test the logic of merging.







unit-testing scala






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 29 at 0:32

























asked May 2 at 21:47









Aidin

1163




1163





bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 2 days ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • I don't know about Scala syntax, but have you considered migrating data to JSON and parse it from the code instead of having it everything in the code?
    – Xtreme Biker
    May 3 at 6:31












  • Without seeing the code that performs this "merging" I find it hard to tell what's going on in here. Without understanding what are you testing, it's hard to suggest improvements for the tests.
    – Rene Saarsoo
    May 3 at 12:25






  • 1




    My team and I typically find that having a "defaults" file in our API test package to be very useful when writing data-oriented tests. If these domain objects need to be used in future, we can rely on the fact that they're determinstic and centralized.
    – erip
    May 11 at 11:42


















  • I don't know about Scala syntax, but have you considered migrating data to JSON and parse it from the code instead of having it everything in the code?
    – Xtreme Biker
    May 3 at 6:31












  • Without seeing the code that performs this "merging" I find it hard to tell what's going on in here. Without understanding what are you testing, it's hard to suggest improvements for the tests.
    – Rene Saarsoo
    May 3 at 12:25






  • 1




    My team and I typically find that having a "defaults" file in our API test package to be very useful when writing data-oriented tests. If these domain objects need to be used in future, we can rely on the fact that they're determinstic and centralized.
    – erip
    May 11 at 11:42
















I don't know about Scala syntax, but have you considered migrating data to JSON and parse it from the code instead of having it everything in the code?
– Xtreme Biker
May 3 at 6:31






I don't know about Scala syntax, but have you considered migrating data to JSON and parse it from the code instead of having it everything in the code?
– Xtreme Biker
May 3 at 6:31














Without seeing the code that performs this "merging" I find it hard to tell what's going on in here. Without understanding what are you testing, it's hard to suggest improvements for the tests.
– Rene Saarsoo
May 3 at 12:25




Without seeing the code that performs this "merging" I find it hard to tell what's going on in here. Without understanding what are you testing, it's hard to suggest improvements for the tests.
– Rene Saarsoo
May 3 at 12:25




1




1




My team and I typically find that having a "defaults" file in our API test package to be very useful when writing data-oriented tests. If these domain objects need to be used in future, we can rely on the fact that they're determinstic and centralized.
– erip
May 11 at 11:42




My team and I typically find that having a "defaults" file in our API test package to be very useful when writing data-oriented tests. If these domain objects need to be used in future, we can rely on the fact that they're determinstic and centralized.
– erip
May 11 at 11:42










1 Answer
1






active

oldest

votes

















up vote
0
down vote













Our best solution to his was to use a generator-like class or function.



val newMovies = DataFrameBuilder().add(1).add(2)


It generates values for fields based on the number we provide. If type is a number, value will become the number itself. If it's a string, value will become name of the field plus the number (e.g. MOVIE_TITLE 1)



Another solution was to use a function that takes some of the fields we care about, and fills the rest with constant values. Like, it takes id and utc_insert_timestamp, and fills everything e






share|improve this answer





















    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "196"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f193503%2freadable-unit-test-lists-of-complex-objects%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    Our best solution to his was to use a generator-like class or function.



    val newMovies = DataFrameBuilder().add(1).add(2)


    It generates values for fields based on the number we provide. If type is a number, value will become the number itself. If it's a string, value will become name of the field plus the number (e.g. MOVIE_TITLE 1)



    Another solution was to use a function that takes some of the fields we care about, and fills the rest with constant values. Like, it takes id and utc_insert_timestamp, and fills everything e






    share|improve this answer

























      up vote
      0
      down vote













      Our best solution to his was to use a generator-like class or function.



      val newMovies = DataFrameBuilder().add(1).add(2)


      It generates values for fields based on the number we provide. If type is a number, value will become the number itself. If it's a string, value will become name of the field plus the number (e.g. MOVIE_TITLE 1)



      Another solution was to use a function that takes some of the fields we care about, and fills the rest with constant values. Like, it takes id and utc_insert_timestamp, and fills everything e






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        Our best solution to his was to use a generator-like class or function.



        val newMovies = DataFrameBuilder().add(1).add(2)


        It generates values for fields based on the number we provide. If type is a number, value will become the number itself. If it's a string, value will become name of the field plus the number (e.g. MOVIE_TITLE 1)



        Another solution was to use a function that takes some of the fields we care about, and fills the rest with constant values. Like, it takes id and utc_insert_timestamp, and fills everything e






        share|improve this answer












        Our best solution to his was to use a generator-like class or function.



        val newMovies = DataFrameBuilder().add(1).add(2)


        It generates values for fields based on the number we provide. If type is a number, value will become the number itself. If it's a string, value will become name of the field plus the number (e.g. MOVIE_TITLE 1)



        Another solution was to use a function that takes some of the fields we care about, and fills the rest with constant values. Like, it takes id and utc_insert_timestamp, and fills everything e







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Oct 29 at 0:37









        Aidin

        1163




        1163






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Code Review Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f193503%2freadable-unit-test-lists-of-complex-objects%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Quarter-circle Tiles

            build a pushdown automaton that recognizes the reverse language of a given pushdown automaton?

            Mont Emei