Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't exclude junit4 for testcontainers jupiter #641

Merged
merged 2 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/rewrite/junit5.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ recipeList:
# Workaround for https://github.com/testcontainers/testcontainers-java/issues/970:
- org.openrewrite.maven.RemoveExclusion:
groupId: org.testcontainers
artifactId: testcontainers
artifactId: '*'
exclusionGroupId: junit
exclusionArtifactId: junit
# Similar for https://github.com/openrewrite/rewrite-testing-frameworks/issues/477
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void classReference() {
java(
"""
import org.junit.Test;

public class Sample {
void method() {
Class<Test> c = Test.class;
Expand All @@ -64,7 +64,7 @@ void method() {
""",
"""
import org.junit.jupiter.api.Test;

public class Sample {
void method() {
Class<Test> c = Test.class;
Expand All @@ -85,10 +85,10 @@ void assertThatReceiver() {
"""
import org.junit.Assert;
import org.junit.Test;

import static java.util.Arrays.asList;
import static org.hamcrest.Matchers.containsInAnyOrder;

public class SampleTest {
@SuppressWarnings("ALL")
@Test
Expand All @@ -100,11 +100,11 @@ public void filterShouldRemoveUnusedConfig() {
""",
"""
import org.junit.jupiter.api.Test;

import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;

public class SampleTest {
@SuppressWarnings("ALL")
@Test
Expand Down Expand Up @@ -178,6 +178,30 @@ void dontExcludeJunit4DependencyfromTestcontainers() {
rewriteRun(pomXml(before, before));
}

@Test
@Issue("https://github.com/openrewrite/rewrite-testing-frameworks/issues/429")
void dontExcludeJunit4DependencyfromTestcontainersJupiter() {
//language=xml
String before = """
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.jackson</groupId>
<artifactId>test-plugins</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.18.3</version>
<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));
}

@Test
@Issue("https://github.com/openrewrite/rewrite-testing-frameworks/issues/477")
void dontExcludeJunit4DependencyfromSpringBootTestcontainers() {
Expand Down Expand Up @@ -231,7 +255,7 @@ void assertEqualsWithArrayArgumentToAssertArrayEquals() {
java(
"""
import org.junit.Assert;

class MyTest {
void test() {
Assert.assertEquals(new Object[1], new Object[1]);
Expand All @@ -240,7 +264,7 @@ void test() {
""",
"""
import org.junit.jupiter.api.Assertions;

class MyTest {
void test() {
Assertions.assertArrayEquals(new Object[1], new Object[1]);
Expand All @@ -261,16 +285,16 @@ void migrateInheritedTestBeforeAfterAnnotations() {
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class AbstractTest {
@Before
public void before() {
}

@After
public void after() {
}

@Test
public void test() {
}
Expand All @@ -280,16 +304,16 @@ 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() {
}

@AfterEach
public void after() {
}

@Test
public void test() {
}
Expand All @@ -301,10 +325,10 @@ public void test() {
public class A extends AbstractTest {
public void before() {
}

public void after() {
}

public void test() {
}
}
Expand All @@ -313,16 +337,16 @@ 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() {
}

@AfterEach
public void after() {
}

@Test
public void test() {
}
Expand Down