Skip to content

Commit

Permalink
Add fail-at-end flags to provide better info per test-run in the even…
Browse files Browse the repository at this point in the history
…t of failure (#261)

Test polish, leverage anySatisfy for matching single line partial contains
  • Loading branch information
aegershman authored Dec 3, 2021
1 parent 7195ace commit 50717e9
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 40 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,4 @@ jobs:
java-version: 11
cache: maven
- name: build
if: github.event_name != 'workflow_dispatch'
run: ./mvnw --no-transfer-progress -B clean verify -DskipITs --file pom.xml
- name: verify
if: github.event_name != 'push'
run: ./mvnw --no-transfer-progress -B clean verify --file pom.xml
run: ./mvnw --show-version --no-transfer-progress clean verify --file=pom.xml --fail-at-end --batch-mode
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
git config user.name "github-actions[bot]"
- name: publish-release
run: ./mvnw --settings=${{ github.workspace }}/settings.xml --file=pom.xml --activate-profiles=release,release-automation --batch-mode help:active-profiles release:prepare release:perform
run: ./mvnw --show-version --settings=${{ github.workspace }}/settings.xml --file=pom.xml --activate-profiles=release,release-automation help:active-profiles release:prepare release:perform --batch-mode
env:
GITHUB_TOKEN: ${{ github.token }}
SONATYPE_USERNAME: ${{ secrets.OSSRH_USERNAME }}
Expand All @@ -37,6 +37,6 @@ jobs:

- name: rollback
if: ${{ failure() }}
run: ./mvnw --settings=${{github.workspace}}/settings.xml --file=pom.xml --activate-profiles=release,release-automation --batch-mode help:active-profiles release:rollback
run: ./mvnw --show-version --settings=${{github.workspace}}/settings.xml --file=pom.xml --activate-profiles=release,release-automation help:active-profiles release:rollback --batch-mode
env:
GITHUB_TOKEN: ${{ github.token }}
4 changes: 1 addition & 3 deletions src/test/java/org/openrewrite/maven/InitMojoIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ void single_project(MavenExecutionResult result) {
.isSuccessful()
.out()
.info()
.matches(logLines -> logLines.stream()
.anyMatch(logLine -> logLine.contains("Added rewrite-maven-plugin to")),
"Logs success message");
.anySatisfy(line -> assertThat(line).contains("Added rewrite-maven-plugin to"));
}

}
4 changes: 1 addition & 3 deletions src/test/java/org/openrewrite/maven/RemoveMojoIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ void single_project(MavenExecutionResult result) {
.isSuccessful()
.out()
.info()
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("Removed rewrite-maven-plugin from"))
);
.anySatisfy(line -> assertThat(line).contains("Removed rewrite-maven-plugin from"));
}

}
16 changes: 4 additions & 12 deletions src/test/java/org/openrewrite/maven/RewriteDiscoverIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ void rewrite_discover_detail(MavenExecutionResult result) {
.isSuccessful()
.out()
.info()
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("options"))
);
.anySatisfy(line -> assertThat(line).contains("options"));

assertThat(result).out().warn().isEmpty();
}
Expand All @@ -39,9 +37,7 @@ void rewrite_discover_recipe_lookup_case_insensitive(MavenExecutionResult result
.isSuccessful()
.out()
.info()
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("org.openrewrite.java.format.AutoFormat"))
);
.anySatisfy(line -> assertThat(line).contains("org.openrewrite.java.format.AutoFormat"));
}

@MavenTest
Expand All @@ -51,9 +47,7 @@ void rewrite_discover_recursion(MavenExecutionResult result) {
.isSuccessful()
.out()
.info()
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("recipeList"))
);
.anySatisfy(line -> assertThat(line).contains("recipeList"));

assertThat(result).out().warn().isEmpty();
}
Expand Down Expand Up @@ -81,9 +75,7 @@ void rewrite_discover_rewrite_yml(MavenExecutionResult result) {
.isSuccessful()
.out()
.info()
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("com.example.RewriteDiscoverIT.CodeCleanup"))
);
.anySatisfy(line -> assertThat(line).contains("com.example.RewriteDiscoverIT.CodeCleanup"));

assertThat(result).out().warn().isEmpty();
}
Expand Down
12 changes: 3 additions & 9 deletions src/test/java/org/openrewrite/maven/RewriteDryRunIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ void fail_on_dry_run(MavenExecutionResult result) {
.isFailure()
.out()
.error()
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("Applying recipes would make changes"))
);
.anySatisfy(line -> assertThat(line).contains("Applying recipes would make changes"));
}

@MavenTest
Expand All @@ -29,9 +27,7 @@ void multi_module_project(MavenExecutionResult result) {
.isSuccessful()
.out()
.warn()
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("org.openrewrite.java.cleanup.FinalizeLocalVariables"))
);
.anySatisfy(line -> assertThat(line).contains("org.openrewrite.java.cleanup.FinalizeLocalVariables"));
}

@MavenTest
Expand All @@ -40,9 +36,7 @@ void single_project(MavenExecutionResult result) {
.isSuccessful()
.out()
.warn()
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("org.openrewrite.java.format.AutoFormat"))
);
.anySatisfy(line -> assertThat(line).contains("org.openrewrite.java.format.AutoFormat"));
}

}
8 changes: 2 additions & 6 deletions src/test/java/org/openrewrite/maven/RewriteRunIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ void multi_module_project(MavenExecutionResult result) {
.isSuccessful()
.out()
.warn()
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("org.openrewrite.java.cleanup.FinalizeLocalVariables"))
);
.anySatisfy(line -> assertThat(line).contains("org.openrewrite.java.cleanup.FinalizeLocalVariables"));
}

@MavenTest
Expand All @@ -32,9 +30,7 @@ void single_project(MavenExecutionResult result) {
.isSuccessful()
.out()
.warn()
.matches(logLines ->
logLines.stream().anyMatch(logLine -> logLine.contains("org.openrewrite.java.format.AutoFormat"))
);
.anySatisfy(line -> assertThat(line).contains("org.openrewrite.java.format.AutoFormat"));
}

}

0 comments on commit 50717e9

Please sign in to comment.