Skip to content

Commit

Permalink
Also remove exclusion from spring-boot-testcontainers
Browse files Browse the repository at this point in the history
Fixes #477
  • Loading branch information
timtebeek committed Feb 7, 2024
1 parent d93fd26 commit 5551893
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/main/resources/META-INF/rewrite/junit5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ recipeList:
artifactId: testcontainers
exclusionGroupId: junit
exclusionArtifactId: junit
# Similar for https://github.com/openrewrite/rewrite-testing-frameworks/issues/477
- org.openrewrite.maven.RemoveExclusion:
groupId: org.springframework.boot
artifactId: spring-boot-testcontainers
exclusionGroupId: junit
exclusionArtifactId: junit
- org.openrewrite.java.dependencies.RemoveDependency:
groupId: org.junit.vintage
artifactId: junit-vintage-engine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,49 @@ void dontExcludeJunit4DependencyfromTestcontainers() {
rewriteRun(pomXml(before, before));
}

@Test
@Issue("https://github.com/openrewrite/rewrite-testing-frameworks/issues/477")
void dontExcludeJunit4DependencyfromSpringBootTestcontainers() {
//language=xml
String before = """
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>dev.ted</groupId>
<artifactId>testcontainer-migrate</artifactId>
<version>0.0.1</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
""";
// Output identical, but we want to make sure we don't exclude junit4 from testcontainers
rewriteRun(pomXml(before, before));
}

// edge case for deprecated use of assertEquals
// https://junit.org/junit4/javadoc/4.13/org/junit/Assert.html#assertEquals(java.lang.Object%5B%5D,%20java.lang.Object%5B%5D)
@Issue("https://github.com/openrewrite/rewrite-testing-frameworks/pull/384")
Expand Down Expand Up @@ -226,7 +269,7 @@ void migrateInheritedTestBeforeAfterAnnotations() {
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class AbstractTest {
@Before
public void before() {
Expand All @@ -241,11 +284,11 @@ public void test() {
}
}
""",
"""
"""
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class AbstractTest {
@BeforeEach
public void before() {
Expand Down Expand Up @@ -278,7 +321,7 @@ public void test() {
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class A extends AbstractTest {
@BeforeEach
public void before() {
Expand Down

0 comments on commit 5551893

Please sign in to comment.