Issue
I use junit assumptions to decide whether to run a test or not.
Tests where the assumption fails are ignored/skipped by the junit framework.
I wonder why skipped tests are not reported as 'skipped'?
Please have a look at the example:
import static org.junit.Assert.fail;
import org.junit.Assume;
import org.junit.Test;
public class AssumptionTest {
@Test
public void skipAssumptionFailureTest() {
Assume.assumeTrue("foo".equals("bar"));
fail("This should not be reached!");
}
}
Running this test in a maven project results in:
Running AssumptionTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.015 sec
I would prefer to have this test reported as 'skipped'. Is there any chance to achieve this?
(junit 4.8.1; maven 2.2.1; java 1.6.0_21)
Solution
You can't do this out-of-the-box as the only way to skip tests is with the @Ignore
annotation. However, I found a blog post which might just be what you are looking for:
Answered By - dogbane
Answer Checked By - Robin (JavaFixing Admin)