JUnit tests pass in Eclipse but fail in Maven Surefire

前端 未结 17 2007
臣服心动
臣服心动 2020-11-29 17:28

I have written some JUnit tests using JUnit 4 and spring-test libraries. When I run the tests inside Eclipse then run fine and pass. But when I run them using Maven (during

17条回答
  •  醉话见心
    2020-11-29 17:49

    I had the same issue, but the problem for me was that Java assertions (e.g. assert(num > 0)) were not enabled for Eclipse, but were enabled when running maven.

    Therefore running the jUnit tests from Eclipse did not catch trigger the assertion error.

    This is made clear when using jUnit 4.11 (as opposed to the older version I was using) because it prints out the assertion error, e.g.

    java.lang.AssertionError: null
        at com.company.sdk.components.schema.views.impl.InputViewHandler.(InputViewHandler.java:26)
        at test.com.company.sdk.util.TestSchemaExtractor$MockInputViewHandler.(TestSchemaExtractor.java:31)
        at test.com.company.sdk.util.TestSchemaExtractor.testCreateViewToFieldsMap(TestSchemaExtractor.java:48)
    

提交回复
热议问题