Question

I'm using Maven and jUnit.

In test I have an assertion

assertEquals("3", k.calculateArg("2+1.0"));

and I've got error:

junit.framework.ComparisonFailure: expected:<...> but was:<....0>

How can I make Maven to show whole texts? They are not so long to abbreviate.

I use jUnit 3.8.1 (from pom.xml):

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
Was it helpful?

Solution

It looks like JUnit 3.8.1 will abbreviate expected and actual strings iterating forwards and backwards and finding the first difference. Only if the differing parts have the same length, ellipsis will not be inserted. The length of the whole expected and actual strings is not taken into consideration.

As other posters suggested, switching to a newer version of JUnit is advised. The 3.8.1 is more than 10 years old.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top