Skip to content

Commit

Permalink
Refactor OpenTestReportGeneratingListener to work in native images
Browse files Browse the repository at this point in the history
Fixes #3035.
  • Loading branch information
marcphilipp committed Sep 17, 2022
1 parent 7229385 commit 79f47f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ on GitHub.
==== Bug Fixes

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

==== Deprecations and Breaking Changes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ public class OpenTestReportGeneratingListener implements TestExecutionListener {
static final String ENABLED_PROPERTY_NAME = "junit.platform.reporting.open.xml.enabled";
static final String OUTPUT_DIR_PROPERTY_NAME = "junit.platform.reporting.output.dir";

private static final NamespaceRegistry NAMESPACE_REGISTRY = NamespaceRegistry.builder(Namespace.REPORTING_CORE) //
.add("e", Namespace.REPORTING_EVENTS) //
.add("java", Namespace.REPORTING_JAVA) //
.add("junit", JUnitFactory.NAMESPACE, "https://junit.org/junit5/schemas/open-test-reporting/junit-1.9.xsd") //
.build();

private final AtomicInteger idCounter = new AtomicInteger();
private final Map<UniqueId, String> inProgressIds = new ConcurrentHashMap<>();
private DocumentWriter<Events> eventsFileWriter = DocumentWriter.noop();
Expand All @@ -107,10 +101,16 @@ public OpenTestReportGeneratingListener() {
public void testPlanExecutionStarted(TestPlan testPlan) {
ConfigurationParameters config = testPlan.getConfigurationParameters();
if (isEnabled(config)) {
NamespaceRegistry namespaceRegistry = NamespaceRegistry.builder(Namespace.REPORTING_CORE) //
.add("e", Namespace.REPORTING_EVENTS) //
.add("java", Namespace.REPORTING_JAVA) //
.add("junit", JUnitFactory.NAMESPACE,
"https://junit.org/junit5/schemas/open-test-reporting/junit-1.9.xsd") //
.build();
Path eventsXml = OutputDir.create(config.get(OUTPUT_DIR_PROPERTY_NAME)) //
.createFile("junit-platform-events", "xml");
try {
eventsFileWriter = Events.createDocumentWriter(NAMESPACE_REGISTRY, eventsXml);
eventsFileWriter = Events.createDocumentWriter(namespaceRegistry, eventsXml);
reportInfrastructure();
}
catch (Exception e) {
Expand Down

0 comments on commit 79f47f5

Please sign in to comment.