Skip to content

Commit 7afbe90

Browse files
committed
Polish test kit Events
1 parent 44c6742 commit 7afbe90

File tree

1 file changed

+17
-9
lines changed
  • junit-platform-testkit/src/main/java/org/junit/platform/testkit/engine

1 file changed

+17
-9
lines changed

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ public Events assertStatistics(Consumer<EventStatistics> statisticsConsumer) {
256256
* </pre>
257257
*
258258
* @param conditions the conditions to match against; never {@code null}
259+
* @see #assertEventsMatchLoosely(Condition...)
260+
* @see #assertEventsMatchLooselyInOrder(Condition...)
259261
* @see EventConditions
260262
* @see TestExecutionResultConditions
261263
*/
@@ -267,9 +269,10 @@ public final void assertEventsMatchExactly(Condition<? super Event>... condition
267269

268270
/**
269271
* Assert that all provided conditions are matched by an {@linkplain Event event}
270-
* contained in this {@code Events} object regardless of order.
271-
* Note that this method does a partial match, i.e. some events may not match any
272-
* of the provided conditions.
272+
* contained in this {@code Events} object, regardless of order.
273+
*
274+
* <p>Note that this method performs a partial match. Thus, some events may
275+
* not match any of the provided conditions.
273276
*
274277
* <p>Conditions can be imported statically from {@link EventConditions}
275278
* and {@link TestExecutionResultConditions}.
@@ -284,8 +287,11 @@ public final void assertEventsMatchExactly(Condition<? super Event>... condition
284287
* </pre>
285288
*
286289
* @param conditions the conditions to match against; never {@code null}
290+
* @see #assertEventsMatchExactly(Condition...)
291+
* @see #assertEventsMatchLooselyInOrder(Condition...)
287292
* @see EventConditions
288293
* @see TestExecutionResultConditions
294+
* @since 1.7
289295
*/
290296
@SafeVarargs
291297
@SuppressWarnings("varargs")
@@ -298,9 +304,10 @@ public final void assertEventsMatchLoosely(Condition<? super Event>... condition
298304
/**
299305
* Assert that all provided conditions are matched by an {@linkplain Event event}
300306
* contained in this {@code Events} object.
301-
* Note that this method does a partial match, i.e. some events may not match any
302-
* of the provided conditions.
303-
* However, the conditions provided must be in the correct order.
307+
*
308+
* <p>Note that this method performs a partial match. Thus, some events may
309+
* not match any of the provided conditions; however, the conditions provided
310+
* must be in the correct order.
304311
*
305312
* <p>Conditions can be imported statically from {@link EventConditions}
306313
* and {@link TestExecutionResultConditions}.
@@ -315,8 +322,11 @@ public final void assertEventsMatchLoosely(Condition<? super Event>... condition
315322
* </pre>
316323
*
317324
* @param conditions the conditions to match against; never {@code null}
325+
* @see #assertEventsMatchExactly(Condition...)
326+
* @see #assertEventsMatchLoosely(Condition...)
318327
* @see EventConditions
319328
* @see TestExecutionResultConditions
329+
* @since 1.7
320330
*/
321331
@SafeVarargs
322332
@SuppressWarnings("varargs")
@@ -441,9 +451,7 @@ private static boolean isNotInIncreasingOrder(List<Integer> indices) {
441451
}
442452

443453
private static void checkCondition(List<Event> events, SoftAssertions softly, Condition<? super Event> condition) {
444-
boolean matches = events.stream().anyMatch(condition::matches);
445-
446-
if (!matches) {
454+
if (events.stream().noneMatch(condition::matches)) {
447455
softly.fail("Condition did not match any event: " + condition);
448456
}
449457
}

0 commit comments

Comments
 (0)