jeudi 30 avril 2015

how to use parameterized junit when input is from several files?

I used to use Parameterized junit.

I have two files with a long list in each of them.

say

file_a
file_b

I loaded the two big lists into memory and compared each line in a different test.

Unfortunately the list grew too big and I had a memory problem to parse to parse it to json before saving to file.

That's why I split each long list to smaller files. say

file_a_1
file_a_2
file_a_3

and

file_b_1
file_b_2
file_b_3

how can I still use the parameterized junit infra and syntax to compare each corresponding list items, when each list is distributed to few files?

I have tried:

 @Test
    public void compareNewResponseToBaselineReturnsNoLargeDifferences() throws IOException {

        E2EResultShort baseLineList = routingResponseShortRepository.getBaseLine(chunkId);
        E2EResultShort freshRunList = routingResponseShortRepository.getLatestResponse(chunkId);


??? how do I iterate over differet `i` for each test ??

        List<String> testFailureMessages = alternativeShortTotalChecker.checkAllAlternativesShort(baseLine.get(i), freshRun.get(i));
        assertThat("testFailureMessages should be empty", String.join("", testFailureMessages), equalTo(""));
        assertThat("error messages should be null", freshRoutingResponse.regression_error, is(nullValue()));
    }

Aucun commentaire:

Enregistrer un commentaire