Community
Participate
Working Groups
Now that we have Java 1.5, we could consider migrating our tests to JUnit 4. Although I don't see a strong need for it, there are a couple of minor benefits such as getting rid of the TestCase superclass, additional assert methods, easier tests for exceptions, etc. And since there is no good reason to stay with JUnit 3.x either, I guess we should do the switch. Technically, it should be possible to turn all our tests to Junit 4 with some regex search and replace magic.
+1 Though JUnit 4 treats every method that has a @Test annotation as a test, I would prefer to keep the convention that every test must start with "test".
I see your point. With the "test" prefix, the methods names start with a verb and make their meaning more clear. But OTOH, I also don't like the redundancy in @Test testXXX. When you look at the method name as the assumption under test, wouldn't the former of these two look better? @Test public void callBackRequestIsReleasedOnSessionInvalidate() @Test public void testCallBackRequestIsReleasedOnSessionInvalidate() Another point is the tooling support. In the outline, you can easily distinguish testXXX methods from others. But then again, do we have any public methods in our test classes that are not methods?
(In reply to comment #2) > I see your point. With the "test" prefix, the methods names start with a verb > and make their meaning more clear. But OTOH, I also don't like the redundancy > in @Test testXXX. I agree that the redundancy isn't nice. > When you look at the method name as the assumption under test, wouldn't the > former of these two look better? > > @Test > public void callBackRequestIsReleasedOnSessionInvalidate() > > @Test > public void testCallBackRequestIsReleasedOnSessionInvalidate() > > Another point is the tooling support. In the outline, you can easily > distinguish testXXX methods from others. But then again, do we have any public > methods in our test classes that are not methods? Unlikely that there are public methods that aren't tests. However, having every method start with test also allows to filter (Ctr+O + "test"). This is what I prefer over visually distinguish green (=public test) methods from differently colored non-test methods in the outline.
As of commit af36901793519270685d7e1240a5ca8ee110c6f6, all tests have been migrated to JUnit4. I did not change any method names.