Skip to content

Commit ddd9959

Browse files
authored
Cleanup junit vintage engine (#993)
1 parent 97d3a00 commit ddd9959

2 files changed

Lines changed: 128 additions & 0 deletions

File tree

src/main/resources/META-INF/rewrite/junit5.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,16 @@ recipeList:
103103
- org.openrewrite.java.dependencies.RemoveDependency:
104104
groupId: junit
105105
artifactId: junit
106+
- org.openrewrite.maven.RemoveManagedDependency:
107+
groupId: junit
108+
artifactId: junit
106109
- org.openrewrite.java.testing.junit5.ExcludeJUnit4UnlessUsingTestcontainers
107110
- org.openrewrite.java.dependencies.RemoveDependency:
108111
groupId: org.junit.vintage
109112
artifactId: junit-vintage-engine
113+
- org.openrewrite.maven.RemoveManagedDependency:
114+
groupId: org.junit.vintage
115+
artifactId: junit-vintage-engine
110116
- org.openrewrite.maven.ExcludeDependency:
111117
groupId: org.junit.vintage
112118
artifactId: junit-vintage-engine

src/test/java/org/openrewrite/java/testing/junit5/JUnit5MigrationTest.java

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,128 @@ public void hello() {
541541
);
542542
}
543543

544+
@Test
545+
void removeJunitVintageEngineFromMavenBuild() {
546+
rewriteRun(
547+
//language=xml
548+
pomXml(
549+
"""
550+
<project>
551+
<modelVersion>4.0.0</modelVersion>
552+
<groupId>com.example</groupId>
553+
<artifactId>my-project</artifactId>
554+
<version>1.0.0</version>
555+
<dependencies>
556+
<dependency>
557+
<groupId>junit</groupId>
558+
<artifactId>junit</artifactId>
559+
<version>4.13.2</version>
560+
<scope>test</scope>
561+
</dependency>
562+
<dependency>
563+
<groupId>org.junit.vintage</groupId>
564+
<artifactId>junit-vintage-engine</artifactId>
565+
<version>5.7.2</version>
566+
<scope>test</scope>
567+
</dependency>
568+
</dependencies>
569+
</project>
570+
""",
571+
"""
572+
<project>
573+
<modelVersion>4.0.0</modelVersion>
574+
<groupId>com.example</groupId>
575+
<artifactId>my-project</artifactId>
576+
<version>1.0.0</version>
577+
</project>
578+
"""
579+
),
580+
srcTestJava(
581+
java(
582+
"""
583+
import org.junit.Test;
584+
585+
public class MyTest {
586+
@Test
587+
public void hello() {
588+
}
589+
}
590+
""",
591+
"""
592+
import org.junit.jupiter.api.Test;
593+
594+
public class MyTest {
595+
@Test
596+
public void hello() {
597+
}
598+
}
599+
"""
600+
)
601+
)
602+
);
603+
}
604+
605+
@Test
606+
void removeJunitVintageEngineFromMavenDependencyManagement() {
607+
rewriteRun(
608+
//language=xml
609+
pomXml(
610+
"""
611+
<project>
612+
<modelVersion>4.0.0</modelVersion>
613+
<groupId>com.example</groupId>
614+
<artifactId>my-project</artifactId>
615+
<version>1.0.0</version>
616+
<dependencyManagement>
617+
<dependencies>
618+
<dependency>
619+
<groupId>junit</groupId>
620+
<artifactId>junit</artifactId>
621+
<version>4.13.2</version>
622+
</dependency>
623+
<dependency>
624+
<groupId>org.junit.vintage</groupId>
625+
<artifactId>junit-vintage-engine</artifactId>
626+
<version>5.7.2</version>
627+
</dependency>
628+
</dependencies>
629+
</dependencyManagement>
630+
</project>
631+
""",
632+
"""
633+
<project>
634+
<modelVersion>4.0.0</modelVersion>
635+
<groupId>com.example</groupId>
636+
<artifactId>my-project</artifactId>
637+
<version>1.0.0</version>
638+
</project>
639+
"""
640+
),
641+
srcTestJava(
642+
java(
643+
"""
644+
import org.junit.Test;
645+
646+
public class MyTest {
647+
@Test
648+
public void hello() {
649+
}
650+
}
651+
""",
652+
"""
653+
import org.junit.jupiter.api.Test;
654+
655+
public class MyTest {
656+
@Test
657+
public void hello() {
658+
}
659+
}
660+
"""
661+
)
662+
)
663+
);
664+
}
665+
544666
@Test
545667
void bumpSurefireOnOlderMavenVersions() {
546668
rewriteRun(

0 commit comments

Comments
 (0)