Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 361066 - Consider adopting JUnit 4 for tests
Summary: Consider adopting JUnit 4 for tests
Status: RESOLVED FIXED
Alias: None
Product: RAP
Classification: RT
Component: RWT (show other bugs)
Version: 1.5   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: 2.0 RC1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-15 15:07 EDT by Ralf Sternberg CLA
Modified: 2012-12-28 11:51 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Sternberg CLA 2011-10-15 15:07:57 EDT
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.
Comment 1 Rüdiger Herrmann CLA 2011-10-17 15:35:17 EDT
+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".
Comment 2 Ralf Sternberg CLA 2011-10-17 18:47:15 EDT
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?
Comment 3 Rüdiger Herrmann CLA 2011-10-18 09:51:30 EDT
(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.
Comment 4 Ralf Sternberg CLA 2012-12-28 11:51:57 EST
As of commit af36901793519270685d7e1240a5ca8ee110c6f6, all tests have been migrated to JUnit4.
I did not change any method names.