Skip to content

Commit bef6808

Browse files
committed
Fix XUnit parser softfail scenario
The test suite result works but for testcase that was not the case. This fixes it.
1 parent a5ee6da commit bef6808

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

lib/OpenQA/Parser/Format/XUnit.pm

+1-4
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,14 @@ sub parse {
7070
$ts->children('testcase')->each(
7171
sub {
7272
my $tc = shift;
73-
my $tc_result = 'ok';
74-
$tc_result = 'softfail' if ($tc->{softfailures} && $tc->{softfailures} > 0);
75-
$tc_result = 'fail'
76-
if ($tc->{failures} && $tc->{failures} > 0) || ($tc->{errors} && $tc->{errors} > 0);
7773

7874
my $text_fn = "$ts_category-$ts_name-$num";
7975
$text_fn =~ s/[\/.]/_/g;
8076
$text_fn .= '.txt';
8177
my $content = '# Test messages ';
8278
$content .= "# $tc->{name}\n" if $tc->{name};
8379

80+
my $tc_result = 'ok';
8481
for my $out ($tc->children('skipped, passed, error, failure, softfailure')->each) {
8582
if (my $res = $TC_RESULT_BY_TAG{$out->tag}) { $tc_result //= $res }
8683
$content .= '# ' . $out->tag . ": \n\n";

t/30-test_parser.t

+1
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ sub test_xunit_file {
456456
is $parser->results->search_in_details("text", qr/bacon/)->size, 16,
457457
'Overall 11 testsuites, 15 tests are for bacon';
458458
is $parser->generated_tests_output->size, 24, "23 Outputs";
459+
is $parser->results->search_in_details("title", qr/bacon 14/)->size, 1, 'There is one softfailed test case';
459460

460461
my $resultsdir = tempdir;
461462
$parser->write_output($resultsdir);

t/data/xunit_format_example.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
<testcase assertions="0" classname="bacon" name="bacon 1" time="0.001">
1919
<passed message="message" type="type">inner massage</passed>
2020
</testcase>
21-
<testcase assertions="0" classname="bacon" name="bacon 1" time="0.001">
22-
<softfailure message="message" type="type">inner massage</passed>
23-
</testcase>
2421
<testcase assertions="0" classname="bacon" name="bacon 2" time="0.001">
2522
<error message="message" type="type">inner massage</error>
2623
</testcase>
@@ -63,9 +60,12 @@
6360
<testcase name="bacon 12">
6461
<failure message="<b>message</b>" type="<i>type</i>"></failure>
6562
</testcase>
66-
<testcase assertions="0" classname="not bacon" name="bacon 2" time="0.001">
63+
<testcase assertions="0" classname="not bacon" name="bacon 13" time="0.001">
6764
<error message="message" type="type">inner massage</error>
6865
</testcase>
66+
<testcase assertions="0" classname="bacon" name="bacon 14" time="0.001">
67+
<softfailure message="message" type="type">inner massage</softfailure>
68+
</testcase>
6969
</testsuite>
7070
<!-- test suite with only one of verything -->
7171
<testsuite name="one thing" errors="666" tests="777" failures="888" time="0.021">

0 commit comments

Comments
 (0)