KentBeck/junit — Issue #380: @BeforeClass and @AfterClass methods are still run even if no tests will be run.
Author: noel-yap
Created: 2012-02-13 18:53:00+00:00
State: open

PASSES:

@Ignore
public class NotReallyATest {
@BeforeClass
public static void setUpClass() {
fail("setUpClass() should not run");
}

@AfterClass
public static void tearDownClass() {
fail("tearDownClass() should not run");
}

@Test
public void test() {
fail("test() should not run");
}
}

FAILS:

public class NotReallyATest {
@BeforeClass
public static void setUpClass() {
fail("setUpClass() should not run"); // fails here
}

@AfterClass
public static void tearDownClass() {
fail("tearDownClass() should not run"); // fails here
}

@Ignore
@Test
public void test() {
fail("test() should not run");
}
}

FAILS (using Request.filterWith() to filter out tests Categorized as Manual):

@Category(Manual.class)
public class NotReallyATest {
@BeforeClass
public static void setUpClass() {
fail("setUpClass() should not run"); // fails here
}

@AfterClass
public static void tearDownClass() {
fail("tearDownClass() should not run"); // fails here
}

@Test
public void test() {
fail("test() should not run");
}
}