简体   繁体   中英

Extending JUnit 4.11: Unrooted Tests

The goal is to provide different variations of the very same test methods (just like parameterized testing). The problem is that the actual number of necessary test runs depends and is discovered on the go.

The original idea was to create subelements (children) of the test (using the description object of the test metthod addChild ).

When running the code Eclipse View shows that all the discovered and executed tests are placed under "Unrooted Tests". The tests are described using the description.getTestClass() method the test method's Description instance.

Does anyone can explain what is happening and if possible give a solution?

I extend the BlockJUnit4ClassRunner. Also by using Description.addChild one adds a child.

The test runner of eclipse is a custom implementation called RemoteTestRunner. From its source code I learned that the listener mechanism is not responsible for creating the tree of test cases but the actual Runner structure (getDescription) and the actual children. But again not the children of the description but the children of each of the Runner instance.

All in all the code was harder to read and understand than it should be.

So Unrooted testcases are just tests that were reported by the listener process but could not match properly to the actual Runner structure.

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