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

Make @TestProfile work with integration tests #20223

Merged
merged 1 commit into from Sep 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,14 @@
package org.acme.quickstart.lra;

import java.util.List;

import io.quarkus.test.junit.QuarkusTestProfile;

// we use a QuarkusTestProfile to ensure that QuarkusIntegrationTest works properly with them
public class AppTestProfile implements QuarkusTestProfile {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that be in integration-tests/main? What if narayana-lra is moved out of the Quarkus main repo at some point? Wouldn't we then loose coverage of this feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, but we can cross that bridge if we get to it :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

My point is: Will anyone remember to look that closely? Anyway, I just find it confusing that coverage of some test framework aspects is scattered over the repo which makes it hard to validate changes without running full CI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remember :)


@Override
public List<TestResourceEntry> testResources() {
return List.of(new TestResourceEntry(LRAParticipantTestResourceLifecycle.class));
}
}
Expand Up @@ -19,13 +19,13 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import io.restassured.response.Response;

@QuarkusTest
@QuarkusTestResource(LRAParticipantTestResourceLifecycle.class)
@TestProfile(AppTestProfile.class)
@TestHTTPEndpoint(TransactionalResource.class)
public class LRAParticipantTest {
private String coordinatorEndpoint;
Expand Down
@@ -1,7 +1,9 @@
package org.acme.quickstart.lra;

import io.quarkus.test.junit.QuarkusIntegrationTest;
import io.quarkus.test.junit.TestProfile;

@QuarkusIntegrationTest
@TestProfile(AppTestProfile.class)
public class LRAParticipantTestNativeIT extends LRAParticipantTest {
}
Expand Up @@ -4,6 +4,7 @@
import static io.quarkus.test.junit.IntegrationTestUtil.determineTestProfileAndProperties;
import static io.quarkus.test.junit.IntegrationTestUtil.doProcessTestInstance;
import static io.quarkus.test.junit.IntegrationTestUtil.ensureNoInjectAnnotationIsUsed;
import static io.quarkus.test.junit.IntegrationTestUtil.getAdditionalTestResources;
import static io.quarkus.test.junit.IntegrationTestUtil.getSysPropsToRestore;
import static io.quarkus.test.junit.IntegrationTestUtil.handleDevServices;
import static io.quarkus.test.junit.IntegrationTestUtil.readQuarkusArtifactProperties;
Expand Down Expand Up @@ -132,7 +133,9 @@ private IntegrationTestExtensionState doProcessStart(Properties quarkusArtifactP
TestProfileAndProperties testProfileAndProperties = determineTestProfileAndProperties(profile, sysPropRestore);

testResourceManager = new TestResourceManager(requiredTestClass, quarkusTestProfile,
Collections.emptyList(), testProfileAndProperties.testProfile != null
getAdditionalTestResources(testProfileAndProperties.testProfile,
context.getRequiredTestClass().getClassLoader()),
testProfileAndProperties.testProfile != null
&& testProfileAndProperties.testProfile.disableGlobalTestResources(),
devServicesProps);
testResourceManager.init();
Expand Down
Expand Up @@ -2,14 +2,14 @@

import static io.quarkus.test.junit.IntegrationTestUtil.determineBuildOutputDirectory;
import static io.quarkus.test.junit.IntegrationTestUtil.determineTestProfileAndProperties;
import static io.quarkus.test.junit.IntegrationTestUtil.getAdditionalTestResources;
import static io.quarkus.test.junit.IntegrationTestUtil.getSysPropsToRestore;
import static io.quarkus.test.junit.IntegrationTestUtil.handleDevServices;
import static io.quarkus.test.junit.IntegrationTestUtil.readQuarkusArtifactProperties;

import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -114,7 +114,9 @@ private ArtifactLauncher.LaunchResult doProcessStart(ExtensionContext context, S
TestProfileAndProperties testProfileAndProperties = determineTestProfileAndProperties(profile, sysPropRestore);

testResourceManager = new TestResourceManager(requiredTestClass, profile,
Collections.emptyList(), testProfileAndProperties.testProfile != null
getAdditionalTestResources(testProfileAndProperties.testProfile,
context.getRequiredTestClass().getClassLoader()),
testProfileAndProperties.testProfile != null
&& testProfileAndProperties.testProfile.disableGlobalTestResources());
testResourceManager.init();
Map<String, String> additionalProperties = new HashMap<>(testProfileAndProperties.properties);
Expand Down