Skip to content

Commit 250e3c7

Browse files
committed
Polishing
1 parent 3fac3e9 commit 250e3c7

File tree

36 files changed

+112
-123
lines changed

36 files changed

+112
-123
lines changed

documentation/src/test/java/example/DynamicTestsDemo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Stream<DynamicTest> dynamicTestsFromStream() {
9797
Stream<DynamicTest> dynamicTestsFromIntStream() {
9898
// Generates tests for the first 10 even integers.
9999
return IntStream.iterate(0, n -> n + 2).limit(10)
100-
.mapToObj(n -> dynamicTest("test" + n, () -> assertTrue(n % 2 == 0)));
100+
.mapToObj(n -> dynamicTest("test" + n, () -> assertEquals(0, n % 2)));
101101
}
102102

103103
@TestFactory

documentation/src/test/java/example/defaultmethods/EqualsContract.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
package example.defaultmethods;
1212

1313
import static org.junit.jupiter.api.Assertions.assertEquals;
14-
import static org.junit.jupiter.api.Assertions.assertFalse;
1514
import static org.junit.jupiter.api.Assertions.assertNotEquals;
1615

1716
import org.junit.jupiter.api.Test;
@@ -30,7 +29,7 @@ default void valueEqualsItself() {
3029
@Test
3130
default void valueDoesNotEqualNull() {
3231
T value = createValue();
33-
assertFalse(value.equals(null));
32+
assertNotEquals(null, value);
3433
}
3534

3635
@Test

junit-jupiter-api/src/main/java/org/junit/jupiter/api/io/CleanupMode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ public enum CleanupMode {
4848
/**
4949
* Never clean up a temporary directory after the test has completed.
5050
*/
51-
NEVER;
51+
NEVER
5252

5353
}

junit-jupiter-engine/src/test/java/org/junit/jupiter/api/AssertAllAssertionsTests.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import static org.junit.jupiter.api.Assertions.assertNotNull;
2020
import static org.junit.jupiter.api.Assertions.assertThrows;
2121
import static org.junit.jupiter.api.Assertions.assertTrue;
22+
import static org.junit.jupiter.api.Assertions.fail;
2223

2324
import java.io.IOException;
2425
import java.util.Collection;
@@ -102,8 +103,8 @@ void assertAllWithExecutablesThatThrowAssertionErrors() {
102103
// @formatter:off
103104
MultipleFailuresError multipleFailuresError = assertThrows(MultipleFailuresError.class, () ->
104105
assertAll(
105-
() -> assertFalse(true),
106-
() -> assertFalse(true)
106+
() -> fail(),
107+
() -> fail()
107108
)
108109
);
109110
// @formatter:on
@@ -116,8 +117,8 @@ void assertAllWithCollectionOfExecutablesThatThrowAssertionErrors() {
116117
// @formatter:off
117118
MultipleFailuresError multipleFailuresError = assertThrows(MultipleFailuresError.class, () ->
118119
assertAll(asList(
119-
() -> assertFalse(true),
120-
() -> assertFalse(true)
120+
() -> fail(),
121+
() -> fail()
121122
))
122123
);
123124
// @formatter:on
@@ -130,8 +131,8 @@ void assertAllWithStreamOfExecutablesThatThrowAssertionErrors() {
130131
// @formatter:off
131132
MultipleFailuresError multipleFailuresError = assertThrows(MultipleFailuresError.class, () ->
132133
assertAll(Stream.of(
133-
() -> assertFalse(true),
134-
() -> assertFalse(true)
134+
() -> fail(),
135+
() -> fail()
135136
))
136137
);
137138
// @formatter:on

junit-jupiter-engine/src/test/java/org/junit/jupiter/api/AssertArrayEqualsAssertionsTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ class AssertArrayEqualsAssertionsTests {
2727

2828
@Test
2929
void assertArrayEqualsWithNulls() {
30-
assertArrayEquals((boolean[]) null, (boolean[]) null);
31-
assertArrayEquals((char[]) null, (char[]) null);
32-
assertArrayEquals((byte[]) null, (byte[]) null);
33-
assertArrayEquals((int[]) null, (int[]) null);
34-
assertArrayEquals((long[]) null, (long[]) null);
35-
assertArrayEquals((float[]) null, (float[]) null);
36-
assertArrayEquals((double[]) null, (double[]) null);
37-
assertArrayEquals((Object[]) null, (Object[]) null);
30+
assertArrayEquals(null, (boolean[]) null);
31+
assertArrayEquals(null, (char[]) null);
32+
assertArrayEquals(null, (byte[]) null);
33+
assertArrayEquals(null, (int[]) null);
34+
assertArrayEquals(null, (long[]) null);
35+
assertArrayEquals(null, (float[]) null);
36+
assertArrayEquals(null, (double[]) null);
37+
assertArrayEquals(null, (Object[]) null);
3838
}
3939

4040
@Test

junit-jupiter-engine/src/test/java/org/junit/jupiter/api/AssertDoesNotThrowAssertionsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void assertDoesNotThrowWithMethodReferenceForVoidReturnType() {
7373
assertDoesNotThrow(foo::normalMethod);
7474

7575
// Explicitly as an Executable
76-
assertDoesNotThrow((Executable) foo::normalMethod);
76+
assertDoesNotThrow(foo::normalMethod);
7777
assertDoesNotThrow((Executable) foo::overloaded);
7878
}
7979

@@ -152,7 +152,7 @@ void assertDoesNotThrowWithExecutableThatThrowsARuntimeExceptionWithMessage() {
152152
@Test
153153
void assertDoesNotThrowWithExecutableThatThrowsAnError() {
154154
try {
155-
assertDoesNotThrow((Executable) AssertionTestUtils::recurseIndefinitely);
155+
assertDoesNotThrow(AssertionTestUtils::recurseIndefinitely);
156156
expectAssertionFailedError();
157157
}
158158
catch (AssertionFailedError ex) {

junit-jupiter-engine/src/test/java/org/junit/jupiter/api/AssertLinesMatchAssertionsTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void assertLinesMatchUsingFastForwardMarkerWithLimit3() {
9797
@Test
9898
@SuppressWarnings({ "unchecked", "rawtypes" })
9999
void assertLinesMatchWithNullFails() {
100-
assertThrows(PreconditionViolationException.class, () -> assertLinesMatch((List) null, (List) null));
100+
assertThrows(PreconditionViolationException.class, () -> assertLinesMatch(null, (List) null));
101101
assertThrows(PreconditionViolationException.class, () -> assertLinesMatch(null, Collections.emptyList()));
102102
assertThrows(PreconditionViolationException.class, () -> assertLinesMatch(Collections.emptyList(), null));
103103
}

junit-jupiter-engine/src/test/java/org/junit/jupiter/api/AssumptionsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
package org.junit.jupiter.api;
1212

1313
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
1415
import static org.junit.jupiter.api.Assertions.assertNotNull;
1516
import static org.junit.jupiter.api.Assertions.assertThrows;
16-
import static org.junit.jupiter.api.Assertions.assertTrue;
1717
import static org.junit.jupiter.api.Assumptions.abort;
1818
import static org.junit.jupiter.api.Assumptions.assumeFalse;
1919
import static org.junit.jupiter.api.Assumptions.assumeTrue;
@@ -226,7 +226,7 @@ private static void assertTestAbortedException(String expectedMessage, Executabl
226226
expectTestAbortedException();
227227
}
228228
catch (Throwable ex) {
229-
assertTrue(ex instanceof TestAbortedException);
229+
assertInstanceOf(TestAbortedException.class, ex);
230230
assertMessageEquals(ex, expectedMessage);
231231
}
232232
}

junit-jupiter-engine/src/test/java/org/junit/jupiter/api/FailAssertionsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void failWithThrowable() {
113113
@Test
114114
void failWithStringAndNullThrowable() {
115115
try {
116-
fail("message", (Throwable) null);
116+
fail("message", null);
117117
expectAssertionFailedError();
118118
}
119119
catch (AssertionFailedError ex) {
@@ -127,7 +127,7 @@ void failWithStringAndNullThrowable() {
127127
@Test
128128
void failWithNullStringAndThrowable() {
129129
try {
130-
fail((String) null, new Throwable("cause"));
130+
fail(null, new Throwable("cause"));
131131
expectAssertionFailedError();
132132
}
133133
catch (AssertionFailedError ex) {

junit-jupiter-engine/src/test/java/org/junit/jupiter/api/condition/AbstractExecutionConditionTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import static java.util.stream.Collectors.toList;
1414
import static org.assertj.core.api.Assertions.assertThat;
15+
import static org.junit.jupiter.api.Assertions.assertFalse;
1516
import static org.junit.jupiter.api.Assertions.assertTrue;
1617
import static org.junit.platform.commons.util.ReflectionUtils.findMethod;
1718
import static org.junit.platform.commons.util.ReflectionUtils.findMethods;
@@ -83,7 +84,7 @@ protected void evaluateCondition() {
8384
}
8485

8586
protected void assertEnabled() {
86-
assertTrue(!this.result.isDisabled(), "Should be enabled");
87+
assertFalse(this.result.isDisabled(), "Should be enabled");
8788
}
8889

8990
protected void assertDisabled() {

0 commit comments

Comments
 (0)