Skip to content

Commit

Permalink
Merge pull request #27 from jain0nikhil/main
Browse files Browse the repository at this point in the history
Adding support to get suite name in json format from testng empty suite file.
  • Loading branch information
ASaiAnudeep authored Jan 4, 2023
2 parents cbab11f + 175e456 commit 222bafe
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/parsers/testng.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ function parse(file) {
for (let i = 0; i < rawTestsWithClasses.length; i++) {
result.suites.push(getTestSuiteFromTest(rawTestsWithClasses[i]));
}
} else {
} else if (suitesWithTests.length === 0){
const suite = suites[0];
result.name = suite['@_name'];
result.duration = suite['@_duration-ms'];
console.log("No suites with tests found");
}
result.status = result.total === result.passed ? 'PASS' : 'FAIL';
Expand Down
9 changes: 9 additions & 0 deletions tests/data/testng/empty-suite.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<testng-results ignored="0" total="0" passed="0" failed="0" skipped="0">
<reporter-output>
</reporter-output>
<suite started-at="2023-01-02T23:56:31 UTC" name="Empty Suite" finished-at="2023-01-02T23:56:31 UTC" duration-ms="0">
<groups>
</groups>
</suite>
</testng-results>
17 changes: 17 additions & 0 deletions tests/parser.testng.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -926,4 +926,21 @@ describe('Parser - TestNG', () => {
});
});

it('single suite with no test', () => {
const result = parse({ type: 'testng', files: ['tests/data/testng/empty-suite.xml'] });
assert.deepEqual(result, {
id: '',
name: 'Empty Suite',
total: 0,
passed: 0,
failed: 0,
errors: 0,
skipped: 0,
retried: 0,
duration: 0,
status: 'PASS',
suites: []
});
});

});

0 comments on commit 222bafe

Please sign in to comment.