Skip to content

Commit 79f47f5

Browse files
committed
Refactor OpenTestReportGeneratingListener to work in native images
Fixes #3035.
1 parent 7229385 commit 79f47f5

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

documentation/src/docs/asciidoc/release-notes/release-notes-5.9.1.adoc

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ on GitHub.
1616
==== Bug Fixes
1717

1818
* `ReflectionSupport.findMethods(...)` now returns a distinct set of methods.
19+
* Execution in GraalVM native images no longer requires `--initialize-at-build-time` for
20+
`OpenTestReportGeneratingListener`.
1921

2022
==== Deprecations and Breaking Changes
2123

junit-platform-reporting/src/main/java/org/junit/platform/reporting/open/xml/OpenTestReportGeneratingListener.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,6 @@ public class OpenTestReportGeneratingListener implements TestExecutionListener {
9090
static final String ENABLED_PROPERTY_NAME = "junit.platform.reporting.open.xml.enabled";
9191
static final String OUTPUT_DIR_PROPERTY_NAME = "junit.platform.reporting.output.dir";
9292

93-
private static final NamespaceRegistry NAMESPACE_REGISTRY = NamespaceRegistry.builder(Namespace.REPORTING_CORE) //
94-
.add("e", Namespace.REPORTING_EVENTS) //
95-
.add("java", Namespace.REPORTING_JAVA) //
96-
.add("junit", JUnitFactory.NAMESPACE, "https://junit.org/junit5/schemas/open-test-reporting/junit-1.9.xsd") //
97-
.build();
98-
9993
private final AtomicInteger idCounter = new AtomicInteger();
10094
private final Map<UniqueId, String> inProgressIds = new ConcurrentHashMap<>();
10195
private DocumentWriter<Events> eventsFileWriter = DocumentWriter.noop();
@@ -107,10 +101,16 @@ public OpenTestReportGeneratingListener() {
107101
public void testPlanExecutionStarted(TestPlan testPlan) {
108102
ConfigurationParameters config = testPlan.getConfigurationParameters();
109103
if (isEnabled(config)) {
104+
NamespaceRegistry namespaceRegistry = NamespaceRegistry.builder(Namespace.REPORTING_CORE) //
105+
.add("e", Namespace.REPORTING_EVENTS) //
106+
.add("java", Namespace.REPORTING_JAVA) //
107+
.add("junit", JUnitFactory.NAMESPACE,
108+
"https://junit.org/junit5/schemas/open-test-reporting/junit-1.9.xsd") //
109+
.build();
110110
Path eventsXml = OutputDir.create(config.get(OUTPUT_DIR_PROPERTY_NAME)) //
111111
.createFile("junit-platform-events", "xml");
112112
try {
113-
eventsFileWriter = Events.createDocumentWriter(NAMESPACE_REGISTRY, eventsXml);
113+
eventsFileWriter = Events.createDocumentWriter(namespaceRegistry, eventsXml);
114114
reportInfrastructure();
115115
}
116116
catch (Exception e) {

0 commit comments

Comments
 (0)