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

Quarkus should be able to run tests in different folders than the "preset" ones #8950

Closed
oscarfh opened this issue Apr 29, 2020 · 17 comments · Fixed by #11717
Closed

Quarkus should be able to run tests in different folders than the "preset" ones #8950

oscarfh opened this issue Apr 29, 2020 · 17 comments · Fixed by #11717

Comments

@oscarfh
Copy link
Contributor

oscarfh commented Apr 29, 2020

Description
This issue comes from: here
I want to separate my unit tests from my integration tests for multiple reasons. To do that, I can add a set sourceSet (in gradle) or similar in maven, but when running the tests, I get this message:

Caused by: java.lang.RuntimeException: The test class class YourTest is not located in any of the directories [classes/scala/native-test, classes/java/test, classes/scala/test, classes/java/native-test, /test-classes, bin/test, classes/kotlin/test, classes/kotlin/native-test]

It should be possible to run tests outside these folder.

Implementation ideas
I don't have any. But if you provide me some guidance, I would love to create the PR for that.

@oscarfh oscarfh added the kind/enhancement New feature or request label Apr 29, 2020
@oscarfh
Copy link
Contributor Author

oscarfh commented May 1, 2020

I was thinking about replacing the logic in io.quarkus.test.common.PathTestHelper#isTestClass with a logic that looks for QuarkusTest annotation or similar.
If I cannot replace it, maybe adding it as an OR conditional? Either it is in the given folder or it is annotated with QuarkusTest? Let me know what you think, I would love to contribute that.

@debae
Copy link
Contributor

debae commented May 4, 2020

Looks like this is a duplicate of #8737

@oscarfh
Copy link
Contributor Author

oscarfh commented May 4, 2020

@debae Hi, no, because I run it using gradle, not Intellij.
#8737 is a known problem when running the test using intellij. While my ticket is about accepting that tests might be in other paths than the ones hardcoded in io.quarkus.test.common.PathTestHelper

@ebramirez
Copy link
Contributor

I get the same error and I'm not using IntelliJ, so it looks like the same problem.

@oscarfh
Copy link
Contributor Author

oscarfh commented May 4, 2020

This line explicitly fails if the class is not in the hardcoded folders.

@aloubyansky
Copy link
Member

Should be fixed with #10459

@aloubyansky aloubyansky added this to the 1.7.0 - master milestone Jul 24, 2020
@augustobmoura
Copy link

I don't think it's fixed, the code is still checking for the "correct" directory, why I can't put my tests in a arbitrary dir is beyond me

The check at

doesn't make any sense

I want to be able to just put my tests in any directory that I want, be it integrationTests or integrationTestsForModuleFooThatShouldPass110PercentAtMay

@Alexander-Krause-Glau
Copy link

Alexander-Krause-Glau commented Dec 2, 2022

This is closed, but there is still no solution to that right? I know there is the @QuarkusIntegrationTest annotation, but I don't want to integration test only via network. I have custom integration tests that use the @QuarkusTest annotation and Testcontainer and require Injection.

Also pinging @augustobmoura , maybe you have a custom solution to this by now?

@aloubyansky
Copy link
Member

@Alexander-Krause-Glau could you describe your issue in more detail? Is it a Gradle project? Do you have a little reproducer or instructions to create one? Thanks.

@Alexander-Krause-Glau
Copy link

Thanks for the reply. I think we are talking about narrow integration tests. Have a look at https://github.com/ExplorViz/landscape-service/blob/master/src/integrationTest/java/net/explorviz/landscape/peristence/cassandra/ReactiveSpanStructureRepositoryTest.java

This is a Gradle Project and in Eclipse when I run this test as JUnit test I get

java.lang.RuntimeException: The test class net.explorviz.landscape.peristence.cassandra.ReactiveSpanStructureRepositoryTest is not located in any of the directories classes/scala/native-integration-test, classes/scala/test, classes/scala/native-integrationTest, /test-classes, out/test, classes/kotlin/test, classes/java/native-integrationTest, classes/kotlin/native-integrationTest, classes/scala/integrationTest, classes/java/integration-test, classes/java/integrationTest, classes/kotlin/native-integration-test, classes/scala/native-test, quarkus-app-classes-test, classes/kotlin/integration-test, classes/java/test, classes/java/native-test, bin/test, classes/java/native-integration-test, classes/kotlin/integrationTest, classes/kotlin/native-test, classes/scala/integration-test

Depite currently failing tests, you can still use the custom Gradle Task integrationTest to execute them.

@aloubyansky
Copy link
Member

@Alexander-Krause-Glau could you enable debug and see if you get a line starting with test dir mapping - logged?

@Alexander-Krause-Glau
Copy link

@Alexander-Krause-Glau could you enable debug and see if you get a line starting with test dir mapping - logged?

Here is the output from the Gradle Task. The Eclipse -> Right Click -> Run as JUnit Test approach (obviously) shows the same behavior as mentioned above:

> Task :integrationTest
test dir mapping - build/classes/java/integrationTest:build/classes/java/main

Btw. I get the same log output if I use quarkus.log.level=INFO or even quarkus.log.level=ERROR.

@aloubyansky
Copy link
Member

Thanks. Yes, I see it changed to debug only in 2.15.0.CR1.

@aloubyansky
Copy link
Member

@glefloch could you please check @Alexander-Krause-Glau's project? I can't seem to get Eclipse to properly import it.

@Alexander-Krause-Glau
Copy link

@aloubyansky Import as Gradle Project in Eclipse, not as Eclipse Project. Dunno if you already did.

@aloubyansky
Copy link
Member

Yes, that's what I did. Are you on zulip @Alexander-Krause-Glau?

@aloubyansky
Copy link
Member

@Alexander-Krause-Glau #29808 should fix it for you.

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

Successfully merging a pull request may close this issue.

6 participants