Community
Participate
Working Groups
There is a "test" template but I think Eclipse should also provide "before" and "after" templates for the typical setUp/tearDown case. Those are the default method names I chose in the template. Here are the templates I made and tested locally: == Name: before Context: Java type members Description: before test method (JUnit 4) @${testType:newType(org.junit.Before)} public void ${setUp}() { ${cursor} } == Name: after Context: Java type members Description: after test method (JUnit 4) @${testType:newType(org.junit.After)} public void ${tearDown}() { ${cursor} } PS: Code body is indented with a tab; not spaces.
> We will not add @After and @Before templates, since the New JUnit Test Case > wizard can generate them when desired. See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=395962#c11
Except the wizard is when creating the class, right? You can have multiple before and after methods with JUnit 4 so that's the reason to add these templates. It's not good enough just to have one (literally one) created with the class; developers can have as many of these as wanted. I get tired of typing the before/after pattern when I require multiple; please reconsider your justification.
As Paul stated, multiple @Before and @After methods can be added to a test class. Also, I generally only need them when the tested class starts growing in complexity. Therefore, I often add them at a later point, not when I create the test class, which I presume would be the case for a lot of developers who practice TDD. I wrote my own templates to deal with this, I would be happy to contribute them back to the project if there is a change of mind on this topic.
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie.