Skip to content

Commit dc43a04

Browse files
committed
Update Javadoc for fireTestSuiteStarted(), fireTestSuiteFinished(),
testSuiteStarted() and testSuiteFinished() to make it clear that not all runners call these methods, but runners that call the started methods should also call the finished methods. Closes #1118
1 parent f4a13cb commit dc43a04

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/main/java/org/junit/runner/notification/RunListener.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ public void testRunFinished(Result result) throws Exception {
7070
}
7171

7272
/**
73-
* Called when a test suite is about to be started.
73+
* Called when a test suite is about to be started. If this method is
74+
* called for a given {@link Description}, then {@link #testSuiteFinished(Description)}
75+
* will also be called for the same {@code Description}.
76+
*
77+
* <p>Note that not all runners will call this method, so runners should
78+
* be prepared to handle {@link #testStarted(Description)} calls for tests
79+
* where there was no cooresponding {@code testSuiteStarted()} call for
80+
* the parent {@code Description}.
7481
*
7582
* @param description the description of the test suite that is about to be run
7683
* (generally a class name)
@@ -81,6 +88,8 @@ public void testSuiteStarted(Description description) throws Exception {
8188

8289
/**
8390
* Called when a test suite has finished, whether the test suite succeeds or fails.
91+
* This method will not be called for a given {@link Description} unless
92+
* {@link #testSuiteStarted(Description)} was called for the same @code Description}.
8493
*
8594
* @param description the description of the test suite that just ran
8695
* @since 4.13

src/main/java/org/junit/runner/notification/RunNotifier.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ protected void notifyListener(RunListener each) throws Exception {
106106
}
107107

108108
/**
109-
* Invoke to tell listeners that a test suite is about to start.
109+
* Invoke to tell listeners that a test suite is about to start. Runners are strongly
110+
* encouraged--but not required--to call this method. If this method is called for
111+
* a given {@link Description} then {@link #fireTestSuiteFinished(Description)} MUST
112+
* be called for the same {@code Description}.
110113
*
111114
* @param description the description of the suite test (generally a class name)
112115
* @since 4.13

0 commit comments

Comments
 (0)