Skip to content

Commit 1251593

Browse files
authored
Small improvements and fixes (#790 / #800)
Numerous small improvements and polishing, for example touch-up of the "demo" project. Closes: #790 PR: #800
1 parent 2753134 commit 1251593

25 files changed

Lines changed: 306 additions & 409 deletions

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ jobs:
9898
env:
9999
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100100
SONAR_TOKEN: "61ab2579215aa8a0024a2f9368fc1298fdecfd18"
101-
run: ./gradlew jacocoTestReport sonarqube --stacktrace -i
101+
run: ./gradlew jacocoTestReport sonar --stacktrace -i
102102

103103
# Code format check
104104
code-format-check:

.infra/checkstyle/import-control.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
<allow pkg=".*" regex="true" />
77
<disallow pkg="com.fasterxml.jackson.*" regex="true"/>
8+
<disallow pkg="org.junit.jupiter.api.Assertions.*" regex="true"/>
89

910
<subpackage name="jupiter.json">
1011
<file name="JacksonNode.java">

build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,7 @@ tasks {
304304
javadoc {
305305
if (releaseBuild) {
306306
javadocTool.set(project.javaToolchains.javadocToolFor {
307-
// create Javadoc with least Java version to get all features
308-
// (e.g. search result page on 20)
307+
// create Javadoc with the minimum Java version needed for our desired features (e.g. search)
309308
languageVersion.set(JavaLanguageVersion.of(21))
310309
})
311310
}

src/demo/java/org/junitpioneer/jupiter/DisableIfTestFailsExtensionDemo.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
package org.junitpioneer.jupiter;
1212

13-
import static org.junit.jupiter.api.Assertions.assertTrue;
14-
import static org.junit.jupiter.api.Assertions.fail;
13+
import static org.assertj.core.api.Assertions.assertThat;
14+
import static org.assertj.core.api.Assertions.fail;
1515

1616
import java.io.IOException;
1717

@@ -38,7 +38,7 @@ void test1() {
3838
@Test
3939
@Order(2)
4040
void test2() {
41-
fail();
41+
fail("fails");
4242
}
4343

4444
@Test
@@ -64,7 +64,7 @@ void test1() {
6464
@Order(2)
6565
void test2() {
6666
// fails test with assertion
67-
assertTrue(false);
67+
assertThat(false).isTrue();
6868
}
6969

7070
@Test

src/demo/java/org/junitpioneer/jupiter/ExpectedToFailExtensionDemo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
package org.junitpioneer.jupiter;
1212

13-
import static org.junit.jupiter.api.Assertions.assertEquals;
13+
import static org.assertj.core.api.Assertions.assertThat;
1414

1515
import org.junit.jupiter.api.Test;
1616

@@ -21,7 +21,7 @@ public class ExpectedToFailExtensionDemo {
2121
@ExpectedToFail
2222
void test() {
2323
int actual = brokenMethod();
24-
assertEquals(10, actual);
24+
assertThat(actual).isEqualTo(10);
2525
}
2626
// end::expected_to_fail[]
2727

@@ -30,7 +30,7 @@ void test() {
3030
@ExpectedToFail("Implementation bug in brokenMethod()")
3131
void doSomething() {
3232
int actual = brokenMethod();
33-
assertEquals(10, actual);
33+
assertThat(actual).isEqualTo(10);
3434
}
3535
// end::expected_to_fail_message[]
3636

src/demo/java/org/junitpioneer/jupiter/StdInOutExtensionDemo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ void testReadLines(StdIn in) throws IOException {
101101
String[] lines = in.capturedLines();
102102

103103
// This is failing
104-
// assertEquals(lines, "line1", "line2");
104+
// assertThat(lines).containsExactly("line1", "line2");
105105

106106
// This is passing
107-
// assertEquals(lines, "line1", "line2", "line3");
107+
// assertThat(lines).containsExactly("line1", "line2", "line3");
108108
}
109109

110110
}

src/demo/java/org/junitpioneer/jupiter/cartesian/BitArgumentProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import org.junit.jupiter.api.extension.ExtensionContext;
1919

20+
// implementation example, does not contain tests
2021
public class BitArgumentProvider {
2122

2223
// tag::cartesian_bit_source_annotation[]

src/demo/java/org/junitpioneer/jupiter/cartesian/CartesianTestExtensionDemo.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.time.temporal.TemporalUnit;
2424
import java.util.Arrays;
2525
import java.util.EnumSet;
26+
import java.util.Map;
2627
import java.util.Objects;
2728
import java.util.concurrent.TimeUnit;
2829
import java.util.function.Predicate;
@@ -178,6 +179,7 @@ static ArgumentSets stringIntFactory() {
178179
}
179180
// end::cartesian_argument_sets_reuse[]
180181

182+
// these tests fail intentionally ~> no @Nested
181183
static class MisconfiguredExamples {
182184

183185
// tag::cartesian_bad_examples[]
@@ -236,7 +238,7 @@ static ArgumentSets resolveTestReporterParam() {
236238

237239
// tag::cartesian_argument_sets_int_argument_provider[]
238240
class IntArgumentsProvider
239-
implements CartesianParameterArgumentsProvider {
241+
implements CartesianParameterArgumentsProvider<Integer> {
240242

241243
@Override
242244
public Stream<Integer> provideArguments(
@@ -282,5 +284,13 @@ ArgumentSets provideArguments() {
282284
}
283285
// end::cartesian_argument_sets_with_non_static_factory[]
284286

287+
static class MyTestReporter implements TestReporter {
288+
289+
@Override
290+
public void publishEntry(Map<String, String> map) {
291+
}
292+
293+
}
294+
285295
}
286296
// @formatter:on

src/demo/java/org/junitpioneer/jupiter/cartesian/MyTestReporter.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/demo/java/org/junitpioneer/jupiter/cartesian/NumberArgumentProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.junit.jupiter.api.extension.ExtensionContext;
2020
import org.junit.jupiter.params.support.AnnotationConsumer;
2121

22+
// implementation example, does not contain tests
2223
public class NumberArgumentProvider {
2324

2425
// tag::cartesian_number_argument_provider[]
@@ -31,7 +32,7 @@ public class NumberArgumentProvider {
3132

3233
}
3334

34-
class NumberArgumentsProvider implements CartesianMethodArgumentsProvider, AnnotationConsumer<NumberSource> {
35+
static class NumberArgumentsProvider implements CartesianMethodArgumentsProvider, AnnotationConsumer<NumberSource> {
3536

3637
private int[] numbers;
3738

0 commit comments

Comments
 (0)