Skip to content

Commit

Permalink
Merge pull request #123 from mikepenz/fix/106
Browse files Browse the repository at this point in the history
Include disabled tests as part of skipped count
  • Loading branch information
mikepenz authored Apr 16, 2021
2 parents 343d8c9 + c0f0851 commit 1f3f85c
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 29 deletions.
70 changes: 70 additions & 0 deletions __tests__/testParser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { resolveFileAndLine, resolvePath, parseFile } from '../src/testParser'
* New test cases:
* Copyright Mike Penz
*/
jest.setTimeout(10000)

describe('resolveFileAndLine', () => {
it('should default to 1 if no line found', async () => {
const { fileName, line } = await resolveFileAndLine(null, 'someClassName', 'not a stacktrace');
Expand Down Expand Up @@ -298,4 +300,72 @@ action.surefire.report.email.InvalidEmailAddressException: Invalid email address
"raw_details": ""
}]);
});

it('should parse disabled tests', async () => {
const { count, skipped, annotations } = await parseFile('test_results/issues/testDisabled.xml');

expect(count).toBe(22);
expect(skipped).toBe(10);
expect(annotations).toStrictEqual([{
path: "factorial_of_value_from_fixture",
start_line: 1,
end_line: 1,
start_column: 0,
end_column: 0,
annotation_level: "failure",
title: "factorial_of_value_from_fixture.factorial_of_value_from_fixture",
message: "tests/failed/main.cpp:58: error: check_eq(3628800, 3628801)",
raw_details: "",
}, {
path: "factorial_of_value_from_fixture[0]",
start_line: 1,
end_line: 1,
start_column: 0,
end_column: 0,
annotation_level: "failure",
title: "factorial_of_value_from_fixture[0].factorial_of_value_from_fixture[0]",
message: "tests/failed/main.cpp:97: error: condition was false",
raw_details: "",
}, {
path: "positive_arguments_must_produce_expected_result",
start_line: 1,
end_line: 1,
start_column: 0,
end_column: 0,
annotation_level: "failure",
title: "positive_arguments_must_produce_expected_result.positive_arguments_must_produce_expected_result",
message: "uncaught std::exception: thrown by test",
raw_details: "",
}, {
path: "positive_arguments_must_produce_expected_result[2]",
start_line: 1,
end_line: 1,
start_column: 0,
end_column: 0,
annotation_level: "failure",
title: "positive_arguments_must_produce_expected_result[2].positive_arguments_must_produce_expected_result[2]",
message: "tests/failed/main.cpp:73: error: condition was false",
raw_details: "",
}, {
path: "test_which_fails_check_eq_with_custom_message",
start_line: 1,
end_line: 1,
start_column: 0,
end_column: 0,
annotation_level: "failure",
title: "test_which_fails_check_eq_with_custom_message.test_which_fails_check_eq_with_custom_message",
message: "tests/failed/main.cpp:49: error: check_eq(6, 7): hello world!",
raw_details: "",
}, {
path: "test_which_throws_unknown_exception",
start_line: 1,
end_line: 1,
start_column: 0,
end_column: 0,
annotation_level: "failure",
title: "test_which_throws_unknown_exception.test_which_throws_unknown_exception",
message: "uncaught unknown exception",
raw_details: "",
}]);
});
});
9 changes: 6 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

24 changes: 0 additions & 24 deletions dist/licenses.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/testParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ async function parseSuite(
: []
for (const testcase of testcases) {
count++
if (testcase.skipped) skipped++
if (testcase.skipped || testcase._attributes.status === 'disabled')
skipped++
if (testcase.failure || testcase.error) {
const stackTrace = (
(testcase.failure && testcase.failure._cdata) ||
Expand Down
39 changes: 39 additions & 0 deletions test_results/issues/testDisabled.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name='factorial' tests='22' disabled='10' failures='4' errors='2'>
<testcase name='disabled_fixture_test' status='disabled'/>
<testcase name='disabled_param_fixture_test[0]' status='disabled'/>
<testcase name='disabled_param_fixture_test[1]' status='disabled'/>
<testcase name='disabled_param_fixture_test[2]' status='disabled'/>
<testcase name='disabled_param_fixture_test[3]' status='disabled'/>
<testcase name='disabled_param_test[0]' status='disabled'/>
<testcase name='disabled_param_test[1]' status='disabled'/>
<testcase name='disabled_param_test[2]' status='disabled'/>
<testcase name='disabled_param_test[3]' status='disabled'/>
<testcase name='disabled_test' status='disabled'/>
<testcase name='factorial_of_value_from_fixture' status='failed'>
<failure message='tests/failed/main.cpp:58: error: check_eq(3628800, 3628801)'/>
</testcase>
<testcase name='factorial_of_value_from_fixture[0]' status='failed'>
<failure message='tests/failed/main.cpp:97: error: condition was false'/>
</testcase>
<testcase name='factorial_of_value_from_fixture[1]' status='passed'/>
<testcase name='factorial_of_value_from_fixture[2]' status='passed'/>
<testcase name='factorial_of_value_from_fixture[3]' status='passed'/>
<testcase name='positive_arguments_must_produce_expected_result' status='errored'>
<error message='uncaught std::exception: thrown by test'/>
</testcase>
<testcase name='positive_arguments_must_produce_expected_result[0]' status='passed'/>
<testcase name='positive_arguments_must_produce_expected_result[1]' status='passed'/>
<testcase name='positive_arguments_must_produce_expected_result[2]' status='failed'>
<failure message='tests/failed/main.cpp:73: error: condition was false'/>
</testcase>
<testcase name='positive_arguments_must_produce_expected_result[3]' status='passed'/>
<testcase name='test_which_fails_check_eq_with_custom_message' status='failed'>
<failure message='tests/failed/main.cpp:49: error: check_eq(6, 7): hello world!'/>
</testcase>
<testcase name='test_which_throws_unknown_exception' status='errored'>
<error message='uncaught unknown exception'/>
</testcase>
</testsuite>
</testsuites>

0 comments on commit 1f3f85c

Please sign in to comment.