Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BeforeClass assumption failures handled differently than in other scopes #784

Open
jnersasi opened this issue Dec 6, 2013 · 0 comments
Open

Comments

@jnersasi
Copy link

jnersasi commented Dec 6, 2013

I am using a subclass of RunListener to listen and respond to JUnit events. I'm having an issue handling assumptionFailures in @BeforeClass annotated methods...

In other scopes (@test or @before methods) assumptionFailures seem to correctly call EachTestNotifier's addFailedAssumption() and in time fireTestAssumptionFailed methods as I would expect. This is from the ParentRunner class:

protected final void runLeaf(Statement statement, Description description,
        RunNotifier notifier) {
    EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
    eachNotifier.fireTestStarted();
    try {
        statement.evaluate();
    } catch (AssumptionViolatedException e) {
        eachNotifier.addFailedAssumption(e);
    } catch (Throwable e) {
        eachNotifier.addFailure(e);
    } finally {
        eachNotifier.fireTestFinished();
    }
} 

When an AssumptionViolatedException is caught, listeners are notified of this.

However, when an assumption failure is raised in a @BeforeClass annotated method instead we get a call to fireTestIgnored as can be seen here:

public void run(final RunNotifier notifier) {
    EachTestNotifier testNotifier = new EachTestNotifier(notifier,
            getDescription());
    try {
        Statement statement = classBlock(notifier);
        statement.evaluate();
    } catch (AssumptionViolatedException e) {
        testNotifier.fireTestIgnored();
    } catch (StoppedByUserException e) {
        throw e;
    } catch (Throwable e) {
        testNotifier.addFailure(e);
    }
}

Now an assumption failure looks the same as an ignored test although there is no corresponding @ignore attribute to glean any information from.

Why is an assumption failure being turned into an ignored test only in this case? Is there a reason it can't be treated as a normal assumptionFailure? Since there is still logic being used to determine the validity of the assumption, this isn't the same as a straight up @ignored test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant