Why is a junit test that is skipped due to an assumption error not reported as skipped?

I use junit assumptions to decide whether to run a test or not.
Tests in which the error fails are ignored / skipped within junit.

I wonder why the missed tests are not reported as "missed"?

Please see an 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 this test to be reported as “skipped”. Is there a chance to achieve this?

(junit 4.8.1; maven 2.2.1; java 1.6.0_21)

+5
source share
3 answers

, - @Ignore. , , , :

+2

Spring Ignore, : @IfProfileValue. ProfileValueSource @ProfileValueSourceConfiguration .

. Spring .

, , , , .

+2

, "".

, /. , ( IGNORE ).

Tools runners also had problems with this, causing erratic reporting. See here for a conversation of Surefire dev with JUnit people and here for a related Eclipse bug .

Now this is not a problem in Maven, and it should not be in the new Eclipses . I am using STS based eclipse.buildId = 2.9.2.201205071000-RELEASEand I am still experiencing this behavior.

EDIT: reference type links do not work.

+2
source

All Articles