Remove listeners after suite completes in RestTestSuiteRunner
We need to remove the reproduce info printer after the suite returns otherwise it might print a bogus line if a subsequent non-rest test fails. The `RunNotifier` is used across suites in the same JVM and the listener sticks to it.
This commit is contained in:
parent
416e328cea
commit
a7a2d9f806
|
@ -412,9 +412,9 @@ public class RestTestSuiteRunner extends ParentRunner<RestTestCandidate> {
|
|||
notifier.fireTestIgnored(rootDescription.getChildren().get(0));
|
||||
return;
|
||||
}
|
||||
|
||||
notifier.addListener(new RestReproduceInfoPrinter());
|
||||
|
||||
final RestReproduceInfoPrinter restReproduceInfoPrinter = new RestReproduceInfoPrinter();
|
||||
notifier.addListener(restReproduceInfoPrinter);
|
||||
try {
|
||||
//the test suite gets run on a separate thread as the randomized context is per thread
|
||||
//once the randomized context is disposed it's not possible to create it again on the same thread
|
||||
final Thread thread = new Thread() {
|
||||
|
@ -436,6 +436,12 @@ public class RestTestSuiteRunner extends ParentRunner<RestTestCandidate> {
|
|||
notifier.fireTestFailure(new Failure(getDescription(),
|
||||
new RuntimeException("Interrupted while waiting for the suite runner? Weird.", e)));
|
||||
}
|
||||
} finally {
|
||||
// remove the listener once the suite is done otherwise it will print
|
||||
// a bogus line if a subsequent test fails that is not a
|
||||
// REST test. The RunNotifier is used across suites!
|
||||
notifier.removeListener(restReproduceInfoPrinter);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue