unbroken-dome / gradle-testsets-plugin

A plugin for the Gradle build system that allows specifying test sets (like integration or acceptance tests).
MIT License
230 stars 50 forks source link

afterEvaluate doesn't set properties in IntelliJ IDEA #104

Closed HelLViS69 closed 4 years ago

HelLViS69 commented 4 years ago

Hello,

I have a multi-module project with the plugin used to separate integrations tests from unit tests.

The plugin works like a charm, but as soon as I moved from JUnit 4 to JUnit 5, properties defined with systemPropery are not read by IntelliJ anymore

This is my environment:

This is my configuration file:

apply plugin: 'org.unbroken-dome.test-sets'

testSets {
    integrationTest
}

integrationTest {
    useJUnitPlatform()

    afterEvaluate {
        systemProperty 'spring.config.additional-location', "file:${project.localConfigRepository}/application.yml"
    }
}

check.dependsOn integrationTest
integrationTest.mustRunAfter test

If I run the integration test from Gradle, everything works If I run the integration test from IntelliJ, the test fails because the application needs some properties defined in application.yml file If I switch back to JUnit 4, everything works

HelLViS69 commented 4 years ago

After testing with an older version of IntelliJ, it works, so the problem should be related to IntelliJ. Sorry for the noise

tkrullmann commented 4 years ago

Hi, as far as I know the JUnit run configurations in IntelliJ don't automatically pick up any configuration from Gradle. There's an option to always run tests with Gradle (Preferences > Gradle > Run tests using), with that it should work.

HelLViS69 commented 4 years ago

Hi, yes, setting IntelliJ to run with Gradle works. However, I always had that set to run usind IntelliJ and it worked until I used JUnit4.