You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running a normal @QuarkusTest with TestProfile without any special getEnabledAlternatives() definition will mistakenly use another TestProfile's mock CDI BEAN declared in getEnabledAlternatives().
My Profiles:
public class MockProfile implements QuarkusTestProfile {
public static class ATag implements QuarkusTestProfile {
@Override
public String getConfigProfile() {
return "test-a-tag";
}
@Override
public Set<String> tags() {
return Set.of("a");
}
@Override
public Set<Class<?>> getEnabledAlternatives() {
return Collections.singleton(MockService.class);
}
}
public static class BTag implements QuarkusTestProfile {
@Override
public String getConfigProfile() {
return "test-b-tag";
}
@Override
public Set<String> tags() {
return Set.of("b");
}
@Override
public Set<Class<?>> getEnabledAlternatives() {
return Collections.emptySet();
}
}
}
TestProfile without mock service
@QuarkusTest
@TestProfile(MockProfile.BTag.class)
public class NormalTest {
@Inject
GreetingService greetingService;
@Test
public void testOk() {
System.out.println("B tag test run");
Assertions.assertEquals("special greeting", greetingService.getSpecialGreet());
}
}
TestProfile with mock service
@QuarkusMainTest
@TestProfile(MockProfile.ATag.class)
public class BugTest {
@Test
@Launch({"person"})
public void bugTest(LaunchResult result) {
System.out.println("B tag test run");
Assertions.assertTrue(result.getOutput().contains("Hello person, mocked greeting!"));
}
}
Expected behavior
CDI BEAN used in tests under a different TestProfile should be isolated from each other.
Actual behavior
NormalTest failed because it uses the Mock Service defined in another TestProfile.
Describe the bug
Running a normal
@QuarkusTest
with TestProfile without any specialgetEnabledAlternatives()
definition will mistakenly use another TestProfile's mock CDI BEAN declared ingetEnabledAlternatives()
.My Profiles:
TestProfile without mock service
TestProfile with mock service
Expected behavior
CDI BEAN used in tests under a different TestProfile should be isolated from each other.
Actual behavior
NormalTest failed because it uses the Mock Service defined in another TestProfile.
How to Reproduce?
quarkus dev
o
and pressr
to run the unit tests with output on.okTest
's failureOutput of
uname -a
orver
Darwin 24.0.0 Darwin Kernel Version 24.0.0: Wed Aug 7 03:09:57 PDT 2024; root:xnu-11215.1.9~22/RELEASE_ARM64_T8112 arm64
Output of
java -version
openjdk version "21.0.5" 2024-10-15 LTS
Quarkus version or git rev
quarkus 3.15.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.8 (36645f6c9b5079805ea5009217e36f2cffd34256)
Additional information
No response
The text was updated successfully, but these errors were encountered: