Skip to content

cucumber-testng: tearDownClass() does not print run summary #1173

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

Closed
lvanderveekens opened this issue Jul 8, 2017 · 2 comments
Closed

cucumber-testng: tearDownClass() does not print run summary #1173

lvanderveekens opened this issue Jul 8, 2017 · 2 comments
Assignees

Comments

@lvanderveekens
Copy link
Contributor

lvanderveekens commented Jul 8, 2017

Summary

The @AfterClass step AbstractTestNGCucumberTests#tearDownClass fails to print the cucumber run summary despite whether all tests are green or not.

In AbstractTestNGCucumberTests there's the following failing snippet:

@AfterClass(alwaysRun = true)
public void tearDownClass() throws Exception {
    testNGCucumberRunner.finish();
}

and TestNGCucumberRunner#finish looks like this:

public void finish() {
    runtime.getEventBus().send(new TestRunFinished(runtime.getEventBus().getTime()));
    runtime.printSummary();
}

Sending the TestRunFinished event to the event bus triggers TestNGReporter's runFinishHandler to close the System.out print stream, which affects other event handlers and code still wanting to write to sysout, e.g. runtime.printSummary() in the method above but also actual TestNG listeners.

private EventHandler<TestRunFinished> runFinishHandler = new EventHandler<TestRunFinished>() {
    @Override
    public void receive(TestRunFinished event) {
        out.close();
    }
};

Possible Solution

Don't close the output stream in runFinishHandler or remove the whole handler because it does nothing else.

Steps to Reproduce (for bugs)

Run a Cucumber TestNG test using the cucumber-testng-2.0.0-SNAPSHOT.jar library.

@lvanderveekens lvanderveekens changed the title cucumber-testng: tearDownClass() does not print summary cucumber-testng: tearDownClass() does not print run summary Jul 8, 2017
@brasmusson brasmusson self-assigned this Jul 8, 2017
@brasmusson
Copy link
Contributor

The TestNGReporter does not know (and should not know) if it is System.out it is printing to, so it should call close(). It is the NiceAppendable that should avoid to close System.out.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants