File tree Expand file tree Collapse file tree 2 files changed +42
-4
lines changed
main/resources/META-INF/rewrite
test/java/org/openrewrite/java/testing/junit5 Expand file tree Collapse file tree 2 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -346,6 +346,8 @@ tags:
346346 - testing
347347 - assertj
348348recipeList :
349+ # First improve the assertions for JUnit, to fix inverted expected/actual values
350+ - org.openrewrite.java.testing.junit5.CleanupAssertions
349351 - org.openrewrite.java.testing.assertj.JUnitAssertArrayEqualsToAssertThat
350352 - org.openrewrite.java.testing.assertj.JUnitAssertEqualsToAssertThat
351353 - org.openrewrite.java.testing.assertj.JUnitAssertFalseToAssertThat
Original file line number Diff line number Diff line change @@ -32,10 +32,7 @@ class CleanupAssertionsTest implements RewriteTest {
3232 public void defaults (RecipeSpec spec ) {
3333 spec
3434 .parser (JavaParser .fromJavaVersion ().classpathFromResources (new InMemoryExecutionContext (), "junit-jupiter-api-5.9" ))
35- .recipe (Environment .builder ()
36- .scanRuntimeClasspath ("org.openrewrite.java.testing.junit5" )
37- .build ()
38- .activateRecipes ("org.openrewrite.java.testing.junit5.CleanupAssertions" ));
35+ .recipeFromResources ("org.openrewrite.java.testing.junit5.CleanupAssertions" );
3936 }
4037
4138 @ DocumentExample
@@ -130,4 +127,43 @@ void test() {
130127 )
131128 );
132129 }
130+
131+ @ Test
132+ void assertNotEqualsInverted () {
133+ //language=java
134+ rewriteRun (
135+ java (
136+ """
137+ import org.junit.jupiter.api.Assertions;
138+ import org.junit.jupiter.api.Test;
139+
140+ class A {
141+ class B {}
142+
143+ @Test
144+ public void FlippedParams(){
145+ B myVariable = new B();
146+
147+ Assertions.assertNotEquals(myVariable, null);
148+ }
149+ }
150+ """ ,
151+ """
152+ import org.junit.jupiter.api.Assertions;
153+ import org.junit.jupiter.api.Test;
154+
155+ class A {
156+ class B {}
157+
158+ @Test
159+ public void FlippedParams(){
160+ B myVariable = new B();
161+
162+ Assertions.assertNotEquals(null, myVariable);
163+ }
164+ }
165+ """
166+ )
167+ );
168+ }
133169}
You can’t perform that action at this time.
0 commit comments