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

The Openrewrite plugin is making the sources configuration of the jvm-test-suite plugin not work #309

Open
thaitangluc2412 opened this issue Jun 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@thaitangluc2412
Copy link

Description
When I use the jvm-test-suite plugin simulation with OpenRewrite, the configuration of the testing suite sources does not work, so no tests can run.

Basic project
Screenshot 2024-06-05 at 16 33 10

Screenshot 2024-06-05 at 16 42 11

build.gradle file

plugins {
    id 'jvm-test-suite'
    id 'java'
//    id 'org.openrewrite.rewrite' version "6.15.1"
}

dependencies {
    implementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
}

testing {
    suites {
        integrationTest(JvmTestSuite) {
            dependencies {
                implementation project()
            }
            sources {
                java {
                    srcDirs = ['src/test/java']
                }
                resources {
                    srcDirs = [ 'src/test/resources' ]
                }
            }

        }
    }
}

Steps to Reproduce

When I use two plugins, jvm-test-suite and java, and run integrationTest with the command ./gradlew integrationTest, it executes the test in the BasicTests class and shows the failed test results because the tests in BasicTests always fail. However, when I uncomment the OpenRewrite plugin in the build.gradle file and run the ./gradlew integrationTest command again, it does nothing and shows Build Successful, which means no tests were executed.

Screenshots

Screenshot 2024-06-05 at 16 52 17

Screenshot 2024-06-05 at 16 51 34

Environment

Openrewrite version: 6.15.1
Gradle version: 8.7
Java version: 17
junit-jupiter version: 5.10.2

Additional Context
I downgraded the OpenRewrite version to 5.7.0, but the problem remains the same

@thaitangluc2412 thaitangluc2412 added the bug Something isn't working label Jun 5, 2024
@timtebeek
Copy link
Contributor

Hi @thaitangluc2412 ; thanks for the detailed report; no idea what might go into that not working as expected. As a workaround you might be able to run rewrite recipes exclusively through an init script instead of adding the plugin to your build.gradle file.

@shanman190
Copy link
Collaborator

shanman190 commented Jun 5, 2024

What I suspect is the issue is this little block of code:
https://github.com/openrewrite/rewrite-gradle-plugin/blob/main/plugin%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenrewrite%2Fgradle%2FRewritePlugin.java#L122-L138

In particular, your test and integrationTest source sets are both pointing to the source folder src/test/java. If you were to run build, you should actually see your test run twice with each task based upon the configuration that you've shared here.

With the jvm-test-suite plugin, Gradle intends for you to use a different folder for each test suite (ie. src/integrationTest/java) normally. Due to the clash, the OpenRewrite plugin disabled the integration test compile task which then means the outputs from that are not available for the test task resulting in a successful build.

To expand upon Tim's earlier workaround, you either need to:

  • Use separate source folders for the additional test suite(s)
  • Use OpenRewrite via the init script method documented here.

NOTE: I do find it a little weird that the OpenRewrite Gradle plugin is disabling other stuff during it's configuration phase. I know why it's doing it, but doing so results in weird issues such as this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Backlog
Development

No branches or pull requests

3 participants