JUnit 4.x : why is @Before never executed?
When I create and run unit tests, (in Eclipse (Galileo) with JUnit 4.5 or 4.82), the @Before is never executed.
I've included some sample code below. I would expect its output to be:
initialize
testGetFour
But it is just:
testGetFour
@BeforeClass and @AfterClass are never executed either.
Can someone tell me why this is?
public class SomeClass
{
public static int getFour()
{
return 4;
}
}
//---
import org.junit.Before;
import org.junit.Test;
import junit.framework.TestCase;
public class TestSomeClass extends TestCase
{
@Before
public void initialize() // This method will never execute (?!).
{
System.err.println("initialize");
}
@Test
public void testGetFour()
{
System.err.println("testGetFour");
assertEquals(4, SomeClass.getFour());
}
}