diff --git a/src/parsers/mstest.js b/src/parsers/mstest.js index 7c282fa..9fb15f8 100644 --- a/src/parsers/mstest.js +++ b/src/parsers/mstest.js @@ -193,6 +193,7 @@ function getTestSuites(rawTestRun) { suite.skipped = suite.cases.filter(i => i.status == "SKIP").length; suite.errors = suite.cases.filter(i => i.status == "ERROR").length; suite.duration = suite.cases.reduce((total, test) => { return total + test.duration }, 0); + suite.status = (suite.failed + suite.errors) > 0 ? "FAIL" : "PASS"; result.push(suite); } @@ -214,6 +215,8 @@ function getTestResult(json) { result.errors = result.suites.reduce((total, suite) => { return total + suite.errors }, 0); result.duration = result.suites.reduce((total, suite) => { return total + suite.duration }, 0); + result.status = (result.failed + result.errors) > 0 ? "FAIL" : "PASS"; + return result; } diff --git a/tests/data/mstest/testresults_pass.trx b/tests/data/mstest/testresults_pass.trx new file mode 100644 index 0000000..e1c5329 --- /dev/null +++ b/tests/data/mstest/testresults_pass.trx @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/parser.mstest.spec.js b/tests/parser.mstest.spec.js index 52d1b7e..7fd54ba 100644 --- a/tests/parser.mstest.spec.js +++ b/tests/parser.mstest.spec.js @@ -27,6 +27,11 @@ describe('Parser - MSTest', () => { }) it('Should map results correctly', () => { + assert.equal(result.status, "FAIL"); + + // assert suite results + assert.equal(result.suites[0].status, "FAIL") + assert.equal(result.suites[0].cases[0].status, "FAIL"); assert.equal(result.suites[0].cases[1].status, "SKIP"); // inconclusive assert.equal(result.suites[0].cases[2].status, "PASS"); @@ -37,7 +42,10 @@ describe('Parser - MSTest', () => { assert.equal(result.suites[0].cases[7].status, "FAIL"); // exception assert.equal(result.suites[0].cases[8].status, "PASS"); + assert.equal(result.suites[1].status, "PASS") assert.equal(result.suites[1].cases[0].status, "PASS"); // datarow + + assert.equal(result.suites[2].status, "PASS") }); it('Should include fullnames for testsuites and testcases', () => { @@ -77,6 +85,11 @@ describe('Parser - MSTest', () => { assert.equal(testSuiteWithAttachments.cases[1].attachments[1].path, expectedPath3) }); + it('Should report overall status as PASS if all tests pass', () => { + const result = parse({ type: 'mstest', files: [`${testDataPath}/testresults_pass.trx`] }); + assert.equal(result.status, "PASS"); + }); + function resolveExpectedResultFilePath(executionId, filePath) { return path.join( "bryan.b.cook_MYCOMPUTER_2023-11-12_19_21_51",