Reputation: 96531
Using Assumptions, I can add a bit more meaning to my tests, but when assumption is false, the tests errors out instead of failing (which is better of course). I wonder, is there a way to skip the test altogether when that happens?
For example, when i am offline, test makes no sense and adds no meaning. I would like to recognize the fact that i am offline and not run the test at all. So, no fail()
, no pass()
, pretend that this test does not even exists.
AppConnector appConn = new AppConnector(url, RequestType.POLL);
Assume.assumeTrue(appConn.connect());
try {
// stuff
} catch (Exception e) {
fail();
}
Upvotes: 4
Views: 759
Reputation: 96531
Using the extended jUnit, i modified my test to include precondition
@RunIf(value = HttpChecker.class, arguments = "http:internal_site_url")
This works as needed. The test will only run when ran from inside the walls of the company, else it won't run at all.
If the test fails, it will fail for a legitimate reason.
Upvotes: 3