jeudi 3 septembre 2015

Should JUnit ParentRunner catch AssertionError?

I have implemented a custom TestRunner based on BlockJUnit4ClassRunner.

My assumption was that any failed assertions (indicating product/requirement issues) would be reported to the notifier via addFailedAssumption() while other exceptions would be reported via addFailure() indicating bugs in the test.

Looking at the results, addFailedAssumption() was never called. In the source code of ParentRunner.runLeaf(), I see

try {
    statement.evaluate();
} catch (AssumptionViolatedException e) {
    eachNotifier.addFailedAssumption(e);
} catch (Throwable e) {
    eachNotifier.addFailure(e);
} finally {
    eachNotifier.fireTestFinished();
}

The exceptions I get are all of type java.lang.AssertionError.

Should ParentRunner catch AssertionError or is there a misunderstanding on my side?

Aucun commentaire:

Enregistrer un commentaire