简体   繁体   中英

Clicking on failures shows nothing in an HTML generated Junit report

I have a Junit html report that is generated from an ant script with the <junitreport> element. Everything looks great except for when I try to view failures, nothing is enumerated in the appropriate frame. I have to click on the test case itself to view all methods that were tested in order to see the failures. This does not apply to errors, only failures.

Here is a screenshot showing the problem. Again, this only happens with the failed assertions, not with unexpected errors within the tests.

尝试显示所有故障时不会列举任何故障。

I figured out the issue. In order to properly have our Junit3 formatted tests run from Ant using Junit4, I had to add the following method to each of my test cases:

public static junit.framework.Test suite() {
        return new junit.framework.JUnit4TestAdapter(SimpleTest.class);
}

The issue with this is that for both failures and errors, the JUnit4TestAdapter adds them as errors. I ended up having to override Junit4TestAdapterCache.testAssumptionFailure(Failure failure) and make sure that it ran result.addFailure(Test, AssertionFailedError) instead of result.addError(Test, Throwable) . I then had to make sure my custom runner ran RunNotifier.fireTestAssumptionFailed when a failure (and not an error) occurred.

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