Best way to automagically migrate tests from JUnit 3 to JUnit 4?

前端 未结 7 1839
天命终不由人
天命终不由人 2020-11-29 20:14

I have a bunch of JUnit 3 classes which extend TestCase and would like to automatically migrate them to be JUnit4 tests with annotations such as @Before,

7条回答
  •  余生分开走
    2020-11-29 21:11

    Nice post. I did the upgrade using Netbeans with the following RegEx strings: (First line search-string, second one replace-string)

    public void test
    @Test\n    public void test
    
    @Override\n.*protected void onSetUp
    @Before\n    protected void onSetUp
    
    @Override\n.*protected void onTearDown
    @After\n    protected void onTearDown
    

    Don't forget to flag the Regular Expression checkbox!

提交回复
热议问题