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

Could not recognize different test set #464

Open
briannqc opened this issue Nov 27, 2018 · 13 comments
Open

Could not recognize different test set #464

briannqc opened this issue Nov 27, 2018 · 13 comments

Comments

@briannqc
Copy link

I'm working on gradle project with the structure like below:

  • main
    • java
    • resource
  • test
    • java
    • resource
  • test-integration
    • java
    • resource

Java Test Runner can only recognize test on /test but not on /test-integration

@jdneo
Copy link
Member

jdneo commented Dec 2, 2018

@quoccuongngo

Does the folder test-integration marked as test folder in the gradle configuration?

@jbrandli
Copy link

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
}

@jdneo
Copy link
Member

jdneo commented Mar 20, 2019

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.

@jbrandli
Copy link

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.

@jbrandli
Copy link

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"]

@jdneo
Copy link
Member

jdneo commented May 16, 2019

Thank you @jbrandli for your feedback. I'll take a look.

@gsiawGH
Copy link

gsiawGH commented Nov 16, 2021

has there been any development for this feature?

@jdneo
Copy link
Member

jdneo commented Aug 1, 2022

Another related issue: redhat-developer/vscode-java#2499

Seems that infer the test source paths according to the .classpath is not good enough.

@lucastheisen
Copy link

My use case is very similar to this use case except that I am using maven and my tests are in src/main/java. This is because these tests are e2e tests using junit5 that we want to run any time our infrastructure changes. So we build them into a container and run that container as part of our CI/CD process. The test code itself rarely changes but the infra is changing constantly. It doesn't make conceptual sense to use the build process of different project to run tests across the entire application suite.

@ikstewa
Copy link

ikstewa commented Dec 22, 2022

Gradle now has support for "JVM Test Suites" as a way to cleanly setup unit and integration tests separately. It would be great to see support for running or determining tests from different test suites.

https://docs.gradle.org/current/userguide/jvm_test_suite_plugin.html

@tehsven
Copy link

tehsven commented Jun 28, 2023

I also just ran into this issue today with the same setup as the ticket description. Are there any workarounds, or planned solutions to this issue?

@Med-H
Copy link

Med-H commented Oct 5, 2023

any news ?

@parthasaradhie
Copy link

any update? im facing the similar issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants