This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
I am running Eclipse 3.3 and it doesn't seem to be aware of Junit 4 test cases. It runs everything as a Junit 3 test case.
In Junit 3, the test methods had to start with "testXxxx()" and the test runner finds them using reflection. In Junit 4, you use an annotation (@Test) that can even take parameters like timeout, expected exceptions, .. See here for details http://junit.sourceforge.net/javadoc_40/index.html
But Eclipse doesn't recognize the @Test annotation. It is still looking for methods beginning with "test...()". This sucks because I would like to use the @Test(timeout=) feature.
I have Junit 4 library added to my project build path. What do I have to do to get this to work?
Sun Certified Programmer for the Java 2 Platform
Joined: Aug 17, 2001
I found the answer to my own question. If your test case extends junit.framework.TestCase (old Junit 3 way), then it will be treated as a Junit 3 test. When I removed the "extends TestCase" then it ran as expected in Junit 4.