@@ -55,6 +55,9 @@ public class WildFlyExtension implements BeforeAllCallback, AfterAllCallback {
5555
5656 @ Override
5757 public void beforeAll (final ExtensionContext context ) throws Exception {
58+ // Validate test mode annotations first - runs for every test class
59+ validateTestModeAnnotations (context );
60+
5861 // Start server (if not already started) - shared across all test classes
5962 final ServerManager serverManager = getOrCreateServerManager (context );
6063
@@ -141,22 +144,33 @@ static Optional<ServerManager> getServer(final ExtensionContext context) {
141144 return Optional .ofNullable (resource ).map (ServerResource ::get );
142145 }
143146
144- private ServerManager createServer (final ExtensionContext context ) {
145- // Check for both @WildFlyTest and @WildFlyDomainTest annotations
147+ /**
148+ * Validates that a test class doesn't have conflicting test mode annotations.
149+ *
150+ * @param context the extension context
151+ *
152+ * @throws JUnitException if both @WildFlyTest and @WildFlyDomainTest are present
153+ */
154+ private void validateTestModeAnnotations (final ExtensionContext context ) {
146155 final Class <?> testClass = context .getRequiredTestClass ();
147156 final boolean hasWildFlyTest = AnnotationSupport
148157 .findAnnotation (testClass , WildFlyTest .class ).isPresent ();
149158 final boolean hasDomainTest = AnnotationSupport
150159 .findAnnotation (testClass , WildFlyDomainTest .class ).isPresent ();
151160
152- // Validate that both annotations are not present
153161 if (hasWildFlyTest && hasDomainTest ) {
154162 throw new JUnitException (
155163 "Test class %s cannot have both @WildFlyTest and @WildFlyDomainTest. Use only one to specify the test mode."
156164 .formatted (testClass .getName ()));
157165 }
166+ }
158167
168+ private ServerManager createServer (final ExtensionContext context ) {
159169 // Determine configuration based on launch type
170+ final Class <?> testClass = context .getRequiredTestClass ();
171+ final boolean hasDomainTest = AnnotationSupport
172+ .findAnnotation (testClass , WildFlyDomainTest .class ).isPresent ();
173+
160174 final Configuration <?> configuration ;
161175 if (hasDomainTest ) {
162176 configuration = DomainConfigurationFactory .create ()
0 commit comments