In my opinion, this cannot be so difficult. So try:
0. Import
You need to import three annotations:
import org.junit.After; import org.junit.Before; import org.junit.Test;`
After making the following changes, you will not need import junit.framework.TestCase; .
1. Annotate test* Methods
All methods starting with public void test must be accompanied by @Test annotation. This task is simple with regex.
2. Annotate the SetUp and TearDown methods
Eclipse generates the following setUp() method:
@Override protected void setUp() throws Exception { }
Must be replaced by:
@Before public void setUp() throws Exception { }
Same for tearDown() :
@Override protected void tearDown() throws Exception { }
replaced by
@After public void tearDown() throws Exception { }
3. Get rid of extends TestCase
Delete exactly one entry in the line file
" extends TestCase"
4. Delete basic methods?
It may be necessary to remove / reorganize the existing core methods that will run the test.
5. Convert the suite() method to @RunWithClass
According to saua's comment, there should be a conversion of the suite() method. Thank saua
@RunWith(Suite.class) @Suite.SuiteClasses({ TestDog.class TestCat.class TestAardvark.class })
Conclusion
I think it is very easy with a set of regular expressions, even if it kills my brain;)
guerda Mar 24 '09 at 13:19 2009-03-24 13:19
source share