0

I have a Quarkus project that has both a test sources folder and a native-test folder. The guidance seems to be that I would have a lot of the same tests (specifically @QuarkusIntegrationTests) in the native-test folder. Is there a way to specify to use the same source set in test as native-test?

It makes sense that one might want to have different tests in the other source-set, but it seems tedious to me to have to keep track of the same tests between the two source-sets. Is there a way to tell the nativeTest task to use the tests from the test source set? Is that what I want? Am I visuallizing the purposes of these tests correctly?

I have assumed I could set up in Gradle a bit of script to copy in relevant tests to the native-test directories when testNative runs but this feels quite hacky.

Snappawapa
  • 1,697
  • 3
  • 20
  • 42

1 Answers1

0

The nativeTest task inherits from the Test task, so you should be able to configure it as the test task.

A problem you may face is that gradle test will run @QuarkusIntegrationTest with the default packaging (this may take time). gradle nativeTest will run all tests event the @QuarkusTest.

Using include / exclude in task configuration may lead to what you want:

nativeTest {
  testClassesDirs = project.sourceSets.nativeTest.output.classesDirs
  include '**/it/*'
}

test {
  exclude '**/it/*'
}

gradle test will run all tests from src/test/java excepts tests in the it package. gradle nativeTest will only run test from src/test/java located in the it package.

Guillaume le Floch
  • 1,083
  • 2
  • 11
  • 23
  • Yep, this turned into a deeper rabbit hole than I expected. Marking as accepted as it got me to where the quesion asked (though I modified the config a little). Related issue I just made: https://github.com/quarkusio/quarkus/issues/23528 – Snappawapa Feb 08 '22 at 21:41