Skip to content

Commit 1a0b8fc

Browse files
committed
Add missing preconditions to Execution in Test Kit
Issue: #1356
1 parent f23a136 commit 1a0b8fc

File tree

1 file changed

+25
-12
lines changed
  • junit-platform-testkit/src/main/java/org/junit/platform/testkit/engine

1 file changed

+25
-12
lines changed

junit-platform-testkit/src/main/java/org/junit/platform/testkit/engine/Execution.java

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.time.Instant;
1717

1818
import org.apiguardian.api.API;
19+
import org.junit.platform.commons.util.Preconditions;
1920
import org.junit.platform.commons.util.ToStringBuilder;
2021
import org.junit.platform.engine.TestDescriptor;
2122
import org.junit.platform.engine.TestExecutionResult;
@@ -35,12 +36,15 @@ public class Execution {
3536
* Create a new instance of an {@code Execution} that finished with the
3637
* provided {@link TestExecutionResult}.
3738
*
38-
* @param testDescriptor the {@code TestDescriptor} that finished
39-
* @param startInstant the {@code Instant} that the {@code Execution} started
40-
* @param endInstant the {@code Instant} that the {@code Execution} completed
39+
* @param testDescriptor the {@code TestDescriptor} that finished;
40+
* never {@code null}
41+
* @param startInstant the {@code Instant} that the {@code Execution} started;
42+
* never {@code null}
43+
* @param endInstant the {@code Instant} that the {@code Execution} completed;
44+
* never {@code null}
4145
* @param executionResult the {@code TestExecutionResult} of the finished
42-
* {@code TestDescriptor}
43-
* @return the newly created {@code Execution} instance
46+
* {@code TestDescriptor}; never {@code null}
47+
* @return the newly created {@code Execution} instance; never {@code null}
4448
*/
4549
public static Execution finished(TestDescriptor testDescriptor, Instant startInstant, Instant endInstant,
4650
TestExecutionResult executionResult) {
@@ -49,14 +53,18 @@ public static Execution finished(TestDescriptor testDescriptor, Instant startIns
4953
}
5054

5155
/**
52-
* Create a new instance of an {@code Execution} that was skipped with the provided
53-
* {@code skipReason}.
56+
* Create a new instance of an {@code Execution} that was skipped with the
57+
* provided {@code skipReason}.
5458
*
55-
* @param testDescriptor the {@code TestDescriptor} that finished
56-
* @param startInstant the {@code Instant} that the {@code Execution} started
57-
* @param endInstant the {@code Instant} that the {@code Execution} completed
58-
* @param skipReason the reason the {@code TestDescriptor} was skipped
59-
* @return the newly created {@code Execution} instance
59+
* @param testDescriptor the {@code TestDescriptor} that finished;
60+
* never {@code null}
61+
* @param startInstant the {@code Instant} that the {@code Execution} started;
62+
* never {@code null}
63+
* @param endInstant the {@code Instant} that the {@code Execution} completed;
64+
* never {@code null}
65+
* @param skipReason the reason the {@code TestDescriptor} was skipped;
66+
* may be {@code null}
67+
* @return the newly created {@code Execution} instance; never {@code null}
6068
*/
6169
public static Execution skipped(TestDescriptor testDescriptor, Instant startInstant, Instant endInstant,
6270
String skipReason) {
@@ -75,6 +83,11 @@ public static Execution skipped(TestDescriptor testDescriptor, Instant startInst
7583
private Execution(TestDescriptor testDescriptor, Instant startInstant, Instant endInstant,
7684
TerminationInfo terminationInfo) {
7785

86+
Preconditions.notNull(testDescriptor, "TestDescriptor must not be null");
87+
Preconditions.notNull(startInstant, "Start Instant must not be null");
88+
Preconditions.notNull(endInstant, "End Instant must not be null");
89+
Preconditions.notNull(terminationInfo, "TerminationInfo must not be null");
90+
7891
this.testDescriptor = testDescriptor;
7992
this.startInstant = startInstant;
8093
this.endInstant = endInstant;

0 commit comments

Comments
 (0)