diff --git a/src/features/run/testing/jvm.ts b/src/features/run/testing/jvm.ts index d7a498c7a0..703bf126c6 100644 --- a/src/features/run/testing/jvm.ts +++ b/src/features/run/testing/jvm.ts @@ -131,13 +131,15 @@ export function jvmParser(): TestOutputParser { const failed = Number(m[2]) + Number(m[3]); const run = Number(m[1]); const skipped = Number(m[4]); + failure = null; + // Surefire reports empty suites (e.g. containers of nested tests); they are not ignored tests. + if (run === 0 && failed === 0 && skipped === 0) return events; events.push({ type: "result", path: [m[6]!], status: failed > 0 ? "failed" : skipped === run ? "skipped" : "passed", durationMs: parseDuration(m[5]), }); - failure = null; return events; } if ((m = SUREFIRE_TOTAL_RE.exec(line))) { diff --git a/src/features/run/testing/parsers.test.ts b/src/features/run/testing/parsers.test.ts index 01bfe59edb..8e2fbfb297 100644 --- a/src/features/run/testing/parsers.test.ts +++ b/src/features/run/testing/parsers.test.ts @@ -665,6 +665,35 @@ org.opentest4j.AssertionFailedError: expected: <3> but was: <2> expect(r.summary).toMatchObject({ passed: 2, failed: 1 }); }); + it("does not count an empty Surefire suite as an ignored test", () => { + const r = results( + jvmParser(), + `[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.152 s -- in com.acme.EmptyTest +[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 2, Time elapsed: 0 s -- in com.acme.DisabledTest +[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.01 s -- in com.acme.UserTest +[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 2 +`, + ); + r.apply([ + { type: "result", path: ["com.acme.DisabledTest", "findAll"], status: "skipped" }, + { type: "result", path: ["com.acme.DisabledTest", "ownerDetails"], status: "skipped" }, + { type: "result", path: ["com.acme.UserTest", "findUser"], status: "passed" }, + ]); + expect(r.get("com.acme.EmptyTest")).toBeUndefined(); + expect(r.counts()).toEqual({ passed: 1, failed: 0, skipped: 2, running: 0, total: 3 }); + }); + + it("leaves a Surefire run with no tests empty", () => { + const r = results( + jvmParser(), + `[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s -- in com.acme.EmptyTest +[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 +`, + ); + expect(r.roots).toEqual([]); + expect(r.counts()).toEqual({ passed: 0, failed: 0, skipped: 0, running: 0, total: 0 }); + }); + it("locates a TestNG failure in the test, past TestNG's own frames", () => { const r = results( jvmParser(),