Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.4.0
* always output stack trace for both test failures and errors
* separate failure output sections with true newlines

## 1.3.1
* updated dependencies:
* xml: '^4.3.0'
Expand Down
7 changes: 3 additions & 4 deletions lib/src/impl/report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
// license that can be found in the LICENSE file.

import 'package:intl/intl.dart';
import 'package:xml/xml.dart';
import 'package:testreport/testreport.dart';
import 'package:junitreport/junitreport.dart';
import 'package:junitreport/src/impl/xml.dart';
import 'package:testreport/testreport.dart';
import 'package:xml/xml.dart';

class XmlReport implements JUnitReport {
static final NumberFormat _milliseconds = NumberFormat('#####0.00#', 'en_US');
Expand Down Expand Up @@ -160,7 +160,6 @@ class XmlReport implements JUnitReport {
} else {
long = message;
}
if (message.isNotEmpty && problem.isFailure) stacktrace = '';

var report = <String>[];
var type = problem.isFailure ? 'Failure' : 'Error';
Expand All @@ -171,7 +170,7 @@ class XmlReport implements JUnitReport {
}
if (long != null) report.add(long);
if (stacktrace.isNotEmpty) report.add('Stacktrace:\n$stacktrace');
return report.join(r'\n\n');
return report.join('\n\n');
}

String _message(int failures, int errors) {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: junitreport
version: 1.3.2-dev
version: 1.4.0
description: Generate JUnit XML reports from dart test runs. Transforms the output of dart or flutter tests to
JUnit style XML

Expand Down
27 changes: 24 additions & 3 deletions tool/example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ and even
two in one go</system-out>
</testcase>
<testcase classname="allresults" name="failing test" time="0.141">
<failure message="1 failure, see stacktrace for details">Failure:\n\nExpected: 'two\n'
<failure message="1 failure, see stacktrace for details">Failure:

Expected: 'two\n'
'lines for seeing how it is rendered'
Actual: 'two\n'
'lines that are not expected'
Expand All @@ -21,31 +23,50 @@ Expected: ... wo\nlines for seeing ...
Actual: ... wo\nlines that are n ...
^
Differ at offset 11


Stacktrace:
package:test expect
tool\example-tests\allresults_test.dart 20:5 main.&lt;fn>
</failure>
</testcase>
<testcase classname="allresults" name="failing test with reason" time="0.03">
<failure message="1 failure, see stacktrace for details">Failure:\n\nExpected: 'should fail'
<failure message="1 failure, see stacktrace for details">Failure:

Expected: 'should fail'
Actual: 'fails'
Which: is different.
Expected: should fai ...
Actual: fails
^
Differ at offset 0
the failure reason


Stacktrace:
package:test expect
tool\example-tests\allresults_test.dart 25:5 main.&lt;fn>
</failure>
</testcase>
<testcase classname="allresults" name="error in test" time="0.036">
<error message="Bad state: oops, it failed">tool\example-tests\allresults_test.dart 29:5 main.&lt;fn>
</error>
</testcase>
<testcase classname="allresults" name="error test and failure" time="0.037">
<failure message="1 failure, see stacktrace for details">Failure:\n\nExpected: 'expected1'
<failure message="1 failure, see stacktrace for details">Failure:

Expected: 'expected1'
Actual: 'actual1'
Which: is different.
Expected: expected1
Actual: actual1
^
Differ at offset 0


Stacktrace:
package:test expect
tool\example-tests\allresults_test.dart 33:5 main.&lt;fn>
</failure>
</testcase>
<testcase classname="allresults" name="skipped top level test" time="0.00">
Expand Down