File tree Expand file tree Collapse file tree
src/test/java/victor/training/cleancode/openrewrite Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import org .junit .jupiter .api .Test ;
44
5- import static org .assertj .core .api .Assertions .assertThat ;
65import static org .junit .jupiter .api .Assertions .assertThrows ;
76import static org .junit .jupiter .api .Assertions .assertTrue ;
87
98class JUnitToAssertJTestDemo {
109 @ Test
1110 void test () {
12- assertThat (notification (false )).isEqualTo ("result" );
13- assertTrue (notification (false ).contains ("es" ));
14- assertTrue (notification (false ).startsWith ("re" ));
11+ assertTrue (testedCode ().contains ("eS" ));
12+ assertTrue (testedCode ().startsWith ("re" ));
1513 }
1614
17- private String notification (boolean shouldThrow ) {
18- if (shouldThrow ) throw new IllegalArgumentException ("Boom" );
19- return "result" ;
15+ private String testedCode () {
16+ return notification (false );
2017 }
2118
19+
2220 @ Test
2321 void testExceptions () {
2422 assertThrows (IllegalArgumentException .class , () -> notification (true ));
2523 }
2624
25+ private String notification (boolean shouldThrow ) {
26+ if (shouldThrow ) throw new IllegalArgumentException ("Boom" );
27+ return "result" ;
28+ }
2729 // 1) run open-rewrite.yaml in IntelliJ, or
2830 // 2) mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:RELEASE -Drewrite.activeRecipes=org.openrewrite.java.testing.assertj.JUnitAssertEqualsToAssertThat -Drewrite.exportDatatables=true
2931
You can’t perform that action at this time.
0 commit comments