I have Junit 4.8.2 and maven 3
Some tests in my application should fail the build in case of failure and some of them shouldn’t (just report that the following optional tests failed)
How can I do it with junit and if I can’t then maybe testng can?
E.g. I have two test cases:
First is not really important and can failed because of connection timeout, service unavailability and so on so on. So if it fail, I don’t want to fail whole build, just to let user know about it and write to console
Second is really important one and if it fail – build should be failed as well
I know about @Ignore – it is not what I’m looking for, because I don’t want to skip any tests.
I know about @Category so if you know how to configure surefire plugin to say: if category com.me.Required – build should be failed in case of failure and if category com.me.Optional – build should not be failed
Consider using the failsafe plugin for your tests that are allowed to fail and set the testFailureIgnore flag to true.
To use the failsafe plugin you have to add the plugin to you pom
The surefire plugin will per default execute test named like Test. The failsafe plugin will per default execute the test named like IT.
Given the tests
and
Running
mvn installwill now result in