I'm working on gradle project with the structure like below:
Java Test Runner can only recognize test on /test but not on /test-integration
@quoccuongngo
Does the folder test-integration marked as test folder in the gradle configuration?
I have the same configuration and issue. The test runner does not see the integration tests unless i add the integration test directory to the test source sets but that behavior is undesirable since then gradle will run the integration tests with the regular unit tests.
I tried setting the test config option in my settings.json file to both of the below and that had no change.
"java.test.defaultConfig": "integrationTest"
"java.test.defaultConfig": "integration-test"
Here is my build.gradle file. The behavior I expect is that since the task is a type "test" that the java test runner is able to recognize it as a seperate test configuration. Or that i can specify that integration tests is the test configuration i want to run.
sourceSets {
main {
java.srcDirs = ['src/main/java']
resources.srcDirs= ['src/main/resources']
}
test {
java.srcDirs = ['src/test/java']
resources.srcDirs = ['src/test/resources']
}
integrationTest{
java.srcDirs = ['src/integration-test/java']
resources.srcDirs = ['src/integration-test/resources']
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}
}
task integrationTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
ignoreFailures = true
}
The behavior I expect is that since the task is a type "test" that the java test runner is able to recognize it as a seperate test configuration. Or that i can specify that integration tests is the test configuration i want to run.
@jbrandli Can you explain more about this? Sorry I do not quite get your idea.
Right now, my integrationTests are not recognized by the java test runner, even though they are junit tests, and they have the gradle category of test.
I can make the java test runner recognize these tests by adding the integration-test directory to the "test" SourceSet configuration, but then i lose the ability to run my integration tests independently of the unit tests.
I would like the java test runner plugin to be able to recognize multiple source sets of tests.
I think the easiest option would be a setting for the extension that allows me to add another name for the test runner to look for.
"additionalTestConfigurations":["integrationTest"]
Thank you @jbrandli for your feedback. I'll take a look.
Most helpful comment
I think the easiest option would be a setting for the extension that allows me to add another name for the test runner to look for.