Is there a way to “fail fast” for junit with the maven surefire plugin?

后端 未结 7 1079
春和景丽
春和景丽 2020-11-28 08:39

I\'m currently working on a java project using maven. We use the maven surefire plugin to run our junit suite as part of the build process.

Our test suite is rapidl

7条回答
  •  情深已故
    2020-11-28 09:13

    This isn't a direct answer to the question, but it can also be useful to feed the output of maven through grep, to strip out most stuff and help you to see where the test failures are.

    Like this:

    mvn test | grep -w 'Running\|Tests'
    

    Which produces output (for my code) like this:

    Running scot.mygov.pp.test.dashboard.DashboardJsonSerDesCRUDTest
    Tests run: 26, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.029 sec
    Running scot.mygov.pp.test.dashboard.DashboardBaselineCRUDTest
    Tests run: 26, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.026 sec
    Running scot.mygov.pp.test.dashboard.DashboardDatabaseValidationTest
    Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.264 sec
    Running scot.mygov.pp.test.dashboard.DashboardServiceWebServiceIsolationCRUDTest
    Tests run: 26, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.032 sec
    

    Much easier to see where the first error of failure is.

提交回复
热议问题