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

QuarkusTestResourceLifecycleManager start/stop executed for each test method in Quarkus 1.13.0.CR1 #16108

Closed
tosix1988 opened this issue Mar 29, 2021 · 0 comments · Fixed by #16112
Assignees
Labels
area/testing kind/bug Something isn't working
Milestone

Comments

@tosix1988
Copy link

Hello,

I have been trying out the Quarkus 1.13.0.CR1 release, and I have noticed the following change in behavior (when comparing with Quarkus 1.12.0.Final) regarding QuarkusTestResourceLifecycleManager. Formerly, the start/stop methods of the lifecycle manager were executed before/after the tests are run, however, with the 1.13.0.CR1 version of Quarkus it seems that they are invoked before each relevant test method.

A simplistic reproducer:

Consider the following resource lifecycle manager:

public class LifecycleManager implements QuarkusTestResourceLifecycleManager {

    @Override
    public Map<String, String> start() {
    	Counter.startCounter.incrementAndGet();
    	return Map.of();
    }

    @Override
    public void stop() {
    	Counter.endCounter.incrementAndGet();
    }

}

where Counter is a class containing two static AtomicInteger fields that count start/stop invocations.
I mark the test to use the resource manager with the following annotation:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@QuarkusTestResource(LifecycleManager.class)
@Stereotype
public @interface CustomResource {}

Now, the following test passes with 1.12.0.Final, but fails with 1.13.0.CR1:

@CustomResource
@QuarkusTest
public class StartTest {

    @Test
    public void test1() {
        assertTrue(Counter.startCounter.get() <= 1);
    }

    @Test
    public void test2() {
        assertTrue(Counter.startCounter.get() <= 1);
    }

}

The same holds for the test that counts the stop invocations. In case this is a feature, is there a way to retain former behavior?

I have attached a reproducer project here: quarkus-resource.zip

@tosix1988 tosix1988 added the kind/bug Something isn't working label Mar 29, 2021
@geoand geoand self-assigned this Mar 30, 2021
geoand added a commit to geoand/quarkus that referenced this issue Mar 30, 2021
This happened when the QuarkusTestResourceLifecycleManager was
 configured in a @QuarkusTestResource that was being used as a
 meta-annotation

Fixes: quarkusio#16108
@quarkus-bot quarkus-bot bot added this to the 1.14 - main milestone Mar 30, 2021
geoand added a commit that referenced this issue Mar 30, 2021
Prevent QuarkusTestResourceLifecycleManager from being run twice
@gsmet gsmet modified the milestones: 1.14 - main, 1.13.1.Final Apr 3, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Apr 3, 2021
This happened when the QuarkusTestResourceLifecycleManager was
 configured in a @QuarkusTestResource that was being used as a
 meta-annotation

Fixes: quarkusio#16108
(cherry picked from commit 9fdd500)
juazugas pushed a commit to juazugas/quarkus that referenced this issue Sep 30, 2021
This happened when the QuarkusTestResourceLifecycleManager was
 configured in a @QuarkusTestResource that was being used as a
 meta-annotation

Fixes: quarkusio#16108
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants