Quarkus: QuarkusTestResources all started no matter what

Created on 23 Jun 2020  路  16Comments  路  Source: quarkusio/quarkus

Describe the bug
I have 2 quarkus test and 2 seperate test resources (1 for starting a MySQL container and another for starting a LocalStack container). Each of the test classes are annotated with @QuarkusTestResource for there resource.

Expected behavior
Since each test class is independent and has different resources I would expect to only see the resource assigned to that class to start

Actual behavior
No matter which test I seem to run both QuarkusTestResourceLifecycleManager seems to start up

To Reproduce
Steps to reproduce the behavior:



    1. 2.
  1. 3.

Configuration

# Add your application.properties here, if applicable.

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of uname -a or ver:
  • Output of java -version:
  • GraalVM version (if different from Java):
  • Quarkus version or git rev:
  • Build tool (ie. output of mvnw --version or gradlew --version):

Additional context
(Add any other context about the problem here.)

kinbug

All 16 comments

Seems related: #9854

@geoand this topic seems to be coming back again and again (in various manifestations).

I was thinking that maybe QuarkusTestResourceLifecycleManagers could somehow be started lazily?
I suppose in that case a manager could not contribute system properties anymore?

With the current design we can't have that - all QuarkusTestResourceLifecycleManager classes are used for all tests.

However, with the advent of QuarkusTestProfile we do plan to make test profile specific QuarkusTestResourceLifecycleManager work.

That probably won't be part of 1.6 though

How is QuarkusTestProfile going to work? Do I have to activate it via a property?

It already works, take a look at the examples in the codebase.

What isn't there is integration with QuarkusTestResourceLifecycleManager (which I doubt I'll have time to get in for 1.6, but you never know)

Ok found the docs: https://github.com/quarkusio/quarkus/pull/9933/files#diff-47ba67a53b8e59e00a94c37fdc60c396

This is a nice improvement. I don't like the sort-by-package approach since packaging shoud be driven by business (and visibility) rules but I do know you cannot do anything about sorting test classes since surefire plugin is deciding that on its own.

I guess -Dtest=... will only active the profile of the selected tests?

Ok found the docs: https://github.com/quarkusio/quarkus/pull/9933/files#diff-47ba67a53b8e59e00a94c37fdc60c396

This is a nice improvement. I don't like the sort-by-package approach since packaging shoud be driven by business (and visibility) rules but I do know you cannot do anything about sorting test classes since surefire plugin is deciding that on its own.

The sorting is proposed as a way of minimizing the number of Quarkus restarts necessary.

I guess -Dtest=... will only active the profile of the selected tests?

It should. If it doesn't, then please open an issue

Btw, back in 2017 there was an attempt to add custom sorting strategies to surefire: https://github.com/apache/maven-surefire/pull/169

are QuarkusTestProfile in 1.5.2.Final?

No, it will part of 1.6.0.Final

Ignore I can see that its targeted towards 1.6.0

@famod did you try using the test profile? Do you have any feedback?

@geoand

@famod did you try using the test profile? Do you have any feedback?

No, sorry. Busy with other stuff.

No worries, thanks

10368 is related to this

Closing this as https://github.com/quarkusio/quarkus/pull/10368 has been merged and will be part of 1.7

Was this page helpful?
0 / 5 - 0 ratings