0

I've got some Junit tests that compare large blocks of JSON using a framework called JsonUnit.

When there is a failure in the test, it's typically just a few lines in a 1000+ line JSON. The JsonUnit framework will give me the exact sections of the JSON that are failing like this:

 but: JSON documents are different:

Different value found in node "sent[0].acknowledgedTime", expected <"09:56:22.216213"> but was .

Different value found in node "sent[0].reopeningNumber", expected <"RA"> but was <"RU">.

Different value found in node "sent[0].sentTime", expected <"09:55:42.776926"> but was <"09:55:53.901321">.

Different value found in node "sent[0].value", expected <1.0E+8> but was <2.0E+10>.

Different value found in node "sent[0].volume", expected <10000> but was <30000>.

I also have large 1000+ line CSVs that I want to compare in a Junit test. If there is a failure, I want it to give me the exact line(s) that failed. Is there a framework out there for CSVs like the JsonUnit?

0

I would simply read the CSV document to a list of Strings and then use AssertJ

assertThat(currentCsvAsLines)
    .contains("some, example, line");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.