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
Update architecture docs for unified test provider (#3313)
* docs: shrink documentation to new technical structure
* docs: replace old provider lookup, diagram and table with updated information
* docs: add breaking changes paragraph for JUnit for 3.6.
* docs: move changes to provider model and new stack trace handling features to architecture.md
* docs: improve distinction between old and new provider model title
* docs: improve distinction between old and new provider model
---------
Signed-off-by: Sebastian Tiemann <setie@mailbox.org>
> Architecture reference for the `master` branch (version 3.5.x).
23
-
> For the upcoming 3.6.0 changes, see [PR #3179 — Unified JUnit Platform Provider](pr-3179-unified-provider.md).
24
22
25
23
## What is Surefire?
26
24
@@ -32,7 +30,9 @@ Apache Maven Surefire is the test execution framework for Maven. It ships three
32
30
|**maven-failsafe-plugin**| Runs integration tests during `integration-test` / `verify` phases |
33
31
|**maven-surefire-report-plugin**| Generates HTML test reports from XML results |
34
32
35
-
Surefire supports JUnit 3, JUnit 4, JUnit 5 (Jupiter), TestNG, and plain POJO tests — each via a dedicated **provider** module. Tests execute in a **forked JVM** that communicates results back to Maven through a binary event stream protocol.
The five `ProviderInfo` implementations (`JUnit3ProviderInfo`, `JUnit4ProviderInfo`, `JUnitCoreProviderInfo`, `TestNgProviderInfo`, `JUnitPlatformProviderInfo`) are collapsed into a unified detection path that always selects `surefire-junit-platform`. Framework-specific configuration (TestNG groups, JUnit 4 categories, parallel execution) is now **mapped to JUnit Platform launcher configuration** rather than being handled by framework-specific providers.
208
+
209
+
183
210
### SurefireProvider SPI
184
211
185
212
Every test framework adapter implements `SurefireProvider` (in `surefire-api`):
@@ -199,6 +226,8 @@ public interface SurefireProvider {
The priority order is defined in `AbstractSurefireMojo.createProviders()`. Surefire resolves the provider's dependencies at runtime via `SurefireDependencyResolver` and adds them to the forked JVM's classpath — the provider JAR is never a compile-time dependency of the plugin.
250
+
| Change | Impact | Mitigation |
251
+
|--------|--------|------------|
252
+
|**JUnit 3 standalone** no longer supported | Projects using only JUnit 3 must add JUnit 4.12+ dependency | Add `junit:junit:4.12` — test code unchanged |
253
+
|**JUnit 4 < 4.12** no longer supported | Upgrade to JUnit 4.12+ | Mechanical version bump |
254
+
|**TestNG < 6.14.3** no longer supported | Upgrade to TestNG 6.14.3+ | Mechanical version bump |
255
+
|**POJO tests** removed | Tests without framework annotations won't be found | Add `@Test` annotations |
256
+
|**Category expression syntax** changed | Complex boolean group expressions may behave differently under JUnit Platform tag expressions | Review and test group filter configurations |
257
+
|**Provider selection** changed | Manually configured legacy providers still work (via SPI) but auto-detection always chooses JUnit Platform | Pin surefire 3.5.x or add legacy provider as dependency |
230
258
231
259
---
232
260
261
+
#### JUnit 3 tests still work
262
+
263
+
JUnit 3 test code does not need to change. You only need to ensure your project depends on JUnit 4.12+ (which includes JUnit 3 API compatibility). The Vintage Engine executes JUnit 3 and JUnit 4 tests transparently.
264
+
265
+
#### POJO tests removed
266
+
267
+
The `LegacyPojoStackTraceWriter` and POJO test detection (`PojoTestSetExecutor`) are removed. Tests must use a recognized framework annotation (`@Test` from JUnit or TestNG).
268
+
269
+
### Group / category filtering
270
+
271
+
The custom JavaCC-based category expression parser (`surefire-grouper`) is replaced by JUnit Platform's native **tag expression** syntax. For most users, `<groups>` and `<excludedGroups>` configuration works unchanged, but the underlying evaluation engine is different. Complex boolean expressions may need review.
272
+
273
+
### Backward compatibility options
274
+
275
+
If upgrading causes issues, users have two fallback paths:
276
+
277
+
1.**Pin Surefire 3.5.x** — stay on the previous version:
278
+
```xml
279
+
<plugin>
280
+
<groupId>org.apache.maven.plugins</groupId>
281
+
<artifactId>maven-surefire-plugin</artifactId>
282
+
<version>3.5.4</version>
283
+
</plugin>
284
+
```
285
+
286
+
2.**Use a legacy provider as a plugin dependency** (transitional):
287
+
```xml
288
+
<plugin>
289
+
<groupId>org.apache.maven.plugins</groupId>
290
+
<artifactId>maven-surefire-plugin</artifactId>
291
+
<version>3.6.0</version>
292
+
<dependencies>
293
+
<dependency>
294
+
<groupId>org.apache.maven.surefire</groupId>
295
+
<artifactId>surefire-junit3</artifactId>
296
+
<version>3.5.4</version>
297
+
</dependency>
298
+
</dependencies>
299
+
</plugin>
300
+
```
301
+
233
302
## Communication Protocol
234
303
235
304
The forked JVM communicates with Maven through a **binary event stream**. Events flow one-way: fork → Maven. Commands flow the other way: Maven → fork.
A new `StackTraceProvider` optimizes memory usage by truncating stack traces to 15 frames and filtering JDK packages by default. This is configurable:
489
+
490
+
```xml
491
+
<configuration>
492
+
<stackTraceFilterPrefixes>
493
+
<prefix>org.springframework.</prefix>
494
+
<prefix>org.junit.</prefix>
495
+
</stackTraceFilterPrefixes>
496
+
</configuration>
497
+
```
498
+
499
+
When not specified or empty, the default filters (`java.`, `javax.`, `sun.`, `jdk.`) apply.
500
+
501
+
---
502
+
503
+
## Stack Trace Memory Optimization
504
+
505
+
### Problem
506
+
507
+
To associate console output with test classes, Surefire captures stack traces for every output line. With full stack traces (25–30 frames typical), this consumed 600–1,800 bytes per line.
508
+
509
+
### Solution
510
+
511
+
The new `StackTraceProvider` class (in `surefire-api`) introduces:
512
+
513
+
-**Frame limit**: Maximum 15 frames per stack trace (sufficient to capture the test class after surefire framework frames)
0 commit comments