apache / apache/maven-surefire

[SUREFIRE-1776] DefaultReportFactory doesn't report errors when engine fails

Open
#3,071 3 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
461
Forks
588
Avg merge
1d 8h
Merged PRs (30d)
19

Description

**[Mickael Istria](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=mickael.istria)** opened **[SUREFIRE-1776](https://issues.apache.org/jira/browse/SUREFIRE-1776?redirect=false)** and commented

We face an issue with tycho-surefire-plugin reporting "No tests found" when a test is actually found but the engine fails (for a tycho-specific reason) when preparing the test.

tycho-surefire-plugin basically builds an OSGi container as defined in the usual Tycho way and uses Surefire API to run the tests inside that container and report it as a plain surefire does regularly.
To do so, it does mainly uses `RunResult result = ProviderFactory.invokeProvider(...)`. However, it can happen that an error happen in the engine, before any test method starts (although the test method is scanned and detected and an executionRequest is emitted for it). The cases for it are relatively probable with Tycho/OSGi.
In such case, even if the engine faced an error, we get a RunResult mentioning no error, actually reporting no test execution, but no error, usually making the test report say everything is fine or telling "No tests found" (which is also incorrect because test is found, it could not just be started).

I could dig a bit more and I think the DefaultTestReporter.mergeTestHistoryResult() method just fails at handling the cases of errors when the error do not happen on the test method, because it wrongly assumes that `listener.getTestMethodStats()` is exhaustive.
More specifically, when debugging this method, I do see in debugger that `this.listeners[0].detailsForThis` has `completedCount==1` and `errors==1` but the return value says completedCount==0 and errors=0; its reportEntries show one error entry, which has for source `` so they're not returned by `listener.getTestMethodStats()`.

I believe the DefaultReportFactory should handle the case to verify before returning whether such unrooted error wasn't missed.

---

**Affects:** 2.22.0

Contributor guide

Open the contributing guide

Research direction

Start with DefaultTestReporter.mergeTestHistoryResult() and DefaultReportFactory, focusing on how listener.getTestMethodStats() handles report entries whose source is . Reproduce the engine-failure scenario described for tycho-surefire-plugin, then verify that the resulting RunResult and test report retain the error instead of reporting no tests found.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.