0

I wrote a unit test that passes when I run it in Eclipse, but fails when I do "maven install".

I use JUnit 4, Mockito 1.9.5, Maven 3.0.4, JRE 1.7._51, Sunfire 2.15.

The assert that seemingly fails is:

assert string1.equals(string2);
Daniil Shevelev
  • 11,739
  • 12
  • 50
  • 73

1 Answers1

1

Answer

Java keyword assert must be activated to work.

They can be activated at run-time by way of the -ea option on the java command, but are not turned on by default.

Some advices

For string comparision use equals

assert string1.equals(string2)

Use junit assertions in test

assertEquals(string1, string2)

For best results use AssertJ - Fluent assertions for java

assertThat(string1).isEqualTo(string2);
Community
  • 1
  • 1
MariuszS
  • 30,646
  • 12
  • 114
  • 155