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 #308

Closed
snowdrop-bot opened this issue Mar 30, 2021 · 0 comments
Assignees
Labels
7 - Community development upstream/closed The issue has been closed in the upstream repository

Comments

@snowdrop-bot
Copy link
Collaborator

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


quarkusio#16108


$upstream:16108$

@snowdrop-bot snowdrop-bot added 7 - Community development upstream/closed The issue has been closed in the upstream repository labels Mar 30, 2021
@geoand geoand closed this as completed Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7 - Community development upstream/closed The issue has been closed in the upstream repository
Projects
None yet
Development

No branches or pull requests

2 participants