Unrooted Tests

2019-01-18 08:42发布

When running all my tests in Eclipse (Eclipse 3.4 'Ganymede'), one test is listed under "Unrooted Tests". I'm using Junit 3.8 and this particular test extends TestCase. I do not see any difference between this test and the other tests. I don't remember seeing this occur in Eclipse 3.3 (Europa).

Clarification:

We haven't moved to JUnit 4.0 yet, so we are not using annotations. I also googled and it seemed like most people were having issues with JUnit 4, but I did not see any solutions. At this point the test passes both locally and in CruiseControl so I'm not overly concerned, but curious.

When I first saw this, though, it was on a failing test that only failed when run with other tests. This led me down the rabbit hole looking for a solution to the "Unrooted" issue that I never found. Eventually I found the culprit in another test that was not properly tearing down.

I agree, it does seem like an Eclipse issue.

21条回答
淡お忘
2楼-- · 2019-01-18 09:11

Do not extend junit.framework.TestCase in your test class with junit1.4 and this should solve the problem

查看更多
Melony?
3楼-- · 2019-01-18 09:12

For me the problem was, that an exception was thrown in the @BeforeClass or @AfterClass methods. This will also cause tests to be categorized as unrooted.

查看更多
We Are One
4楼-- · 2019-01-18 09:13

For me, it was due to the project got build path issues. My maven dependencies configuration needs to be updated.

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-01-18 09:13

I had that problem and putting one "@Test" before the test method solved it!

like this:

@Test public void testOne() { // ... assertTrue(1 == 1); }

查看更多
我想做一个坏孩纸
6楼-- · 2019-01-18 09:13

I got this error with the test method name as "test"

@Test 
public void test() {
 // ... assertTrue(1 == 1); 
}

I renamed the method and it worked

查看更多
smile是对你的礼貌
7楼-- · 2019-01-18 09:18

One other thing you can try is to upgrade your version of JUnit to at least 4.12.

I was experiencing this problem for a while with a class that extended one that used @RunWith(Parameterized.class).

After a while, and I'm sorry that I don't know precisely what I did to cause this, the 'Unrooted Tests' message went away, but the test still didn't run correctly. The constructor that should have accepted arguments from the @Parameters method was never getting called; execution jumped straight from @BeforeClass to @AfterClass.

The fix for that problem was to upgrade JUnit from the 4.8.1 it was using, to the latest (4.12). So maybe that could help someone else in the future.

查看更多
登录 后发表回答