A project aimed at making it easier to build Jenkins compatible XML based JUnit reports.
To install the latest version, run:
npm install junit-report-builder --save
var builder = require('junit-report-builder');
// Create a test suite
var suite = builder.testSuite().name('My suite');
// Create a test case
var testCase = suite.testCase()
.className('my.test.Class')
.name('My first test');
// Create another test case which is marked as failed
var testCase = suite.testCase()
.className('my.test.Class')
.name('My second test')
.failure();
builder.writeTo('test-report.xml');
This will create test-report.xml
containing the following:
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="My suite" tests="2" failures="1" errors="0" skipped="0">
<testcase classname="my.test.Class" name="My first test"/>
<testcase classname="my.test.Class" name="My second test">
<failure/>
</testcase>
</testsuite>
</testsuites>
If you want to create another report file, start by getting a new builder instance like this:
builder = builder.newBuilder();
Please refer to the e2e_spec.coffee for more details on the usage.
- Support attaching files to tests. Thanks to anto-wahanda.
- Support creating XML with emojis. Thanks to ischwarz.
- Changed
date-format
to be a dependency. Previously it was incorrectly set to be a devDependency. Thanks to georgecrawford.
- Added attributes for test count, failure count, error count and skipped test count to testsuite elements
- Added ability to attach standard output and standard error logs to test cases
- Added ability set execution time for test suites
- Added ability set timestamp for test suites
- Simplified API by making the index module export a builder instance
- Corrected example in readme
- Initial release