简体   繁体   中英

JUnit test, Unrooted Tests: initializationError

So I edited the name of a JUnit test and now it wont work. Instead I get Unrooted Tests: initializationError.

This is a simple test. Infact it is a test for JUnit tests as I am just starting to use it.

@Test
public void testRun()
    String s = null;
    assertNull(s);

}

and all i did was change it to testRun2(). Also when I run the file not the individual test, it still runs the old testRun(), not testRun2().

My project has Maven not sure if that is a factor. And I have updated the project

So it turned out that I needed to rebuild using Maven to update the classes. Now it works fine and I can add/modify test cases.

就我而言,我更改了方法名称并且它没有自动更新它,因此上面的 Project> Clean 解决方案对我来说效果很好。

Another way this error would occur is forgetting the Test annotation. Encountered when right click method name in Eclipse and Run As -> Junit Test.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM