quarkusio/quarkus · error · IllegalStateException
A test method annotated with @TestReactiveTransaction must a
Error message
A test method annotated with @TestReactiveTransaction must accept io.quarkus.test.vertx.UniAsserter
What it means
Methods annotated with @TestReactiveTransaction run under a reactive transaction and must use the UniAsserter callback style of Quarkus reactive testing; the interceptor detects whether the method has a UniAsserter parameter. If it does not, there is no way to drive the reactive chain, so the interceptor throws immediately at call time.
Source
Thrown at extensions/panache/hibernate-reactive-panache-common/runtime/src/main/java/io/quarkus/hibernate/reactive/panache/common/runtime/TestReactiveTransactionalInterceptor.java:26
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.InvocationContext;
import io.smallrye.mutiny.Uni;
public class TestReactiveTransactionalInterceptor {
private static final String JUNIT_TEST_ANN = "org.junit.jupiter.api.Test";
private static final String JUNIT_BEFORE_EACH_ANN = "org.junit.jupiter.api.BeforeEach";
private static final String JUNIT_AFTER_EACH_ANN = "org.junit.jupiter.api.AfterEach";
private static final String UNI_ASSERTER_CLASS = "io.quarkus.test.vertx.UniAsserter";
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
if (isSpecialTestMethod(context)) {
return handleSpecialTestMethod(context);
}
// TODO validate this requirement during build
throw new IllegalStateException(
"A test method annotated with @TestReactiveTransaction must accept io.quarkus.test.vertx.UniAsserter");
}
protected boolean isSpecialTestMethod(InvocationContext ic) {
Method method = ic.getMethod();
return hasParameter(UNI_ASSERTER_CLASS, method)
&& (hasAnnotation(JUNIT_TEST_ANN, method)
|| hasAnnotation(JUNIT_BEFORE_EACH_ANN, method)
|| hasAnnotation(JUNIT_AFTER_EACH_ANN, method));
}
protected Object handleSpecialTestMethod(InvocationContext ic) {
// let's not deal with generics/erasure
Class<?>[] parameterTypes = ic.getMethod().getParameterTypes();
Object uniAsserter = null;
Class<?> uniAsserterClass = null;
for (int i = 0; i < parameterTypes.length; i++) {
Class<?> klass = parameterTypes[i];View on GitHub (pinned to e1c734241f)
Solutions
- Add an io.quarkus.test.vertx.UniAsserter parameter to the test method and use asserter.assertThat/Uni assertions
- Remove @TestReactiveTransaction if the test does not need a reactive transaction
- Use plain @TestReactiveTransaction with UniAsserter, or switch to inject + manually chaining Uni for non-test code
Example fix
// before
@TestReactiveTransaction
void testSave() {
entity.persist();
}
// after
@TestReactiveTransaction
void testSave(UniAsserter asserter) {
asserter.assertThat(() -> entity.persist().chain(() -> entity.count()), count -> count == 1);
} Defensive patterns
Strategy: validation
Validate before calling
if (!java.util.Arrays.stream(testMethod.getParameterTypes()).anyMatch(p -> p == io.quarkus.test.vertx.UniAsserter.class)) {
throw new AssertionError("@TestReactiveTransaction test must accept UniAsserter");
} Prevention
- Always add UniAsserter parameter when using @TestReactiveTransaction
- Let the IDE template generate reactive transactional tests
- Review test signatures during code review
When it happens
Trigger: A test method annotated with @TestReactiveTransaction is invoked by the interceptor and its Method has no io.quarkus.test.vertx.UniAsserter parameter (isSpecialTestMethod returns false).
Common situations: Writing a plain void/synchronous test method and annotating it with @TestReactiveTransaction expecting declarative transaction semantics; copy-pasting @Transactional test style into a reactive test; renaming/refactoring that removed the UniAsserter parameter.
Related errors
- %s entities do not support being attached to several persist
- Sort cannot be used with named query, add an "order by" clau
- Entity '%s' was not found. Did you forget to annotate your P
- Unable to perform a projection on a 'select [distinct]? new'
- Cannot call a page related method, call page(Page) or page(i
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/ec6ae739d6a60f12.
Report an issue: GitHub.