Aimed at making it easier to build Jenkins compatible JUnit XML reports in plugins for testing frameworks
$ npm install junit-report-builder
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
import builder from 'junit-report-builder';
// Create a test suite
let suite = builder.testSuite().name('My suite');
// Create a test case
let firstTestCase = suite.testCase()
.className('my.test.Class')
.name('My first test');
// Create another test case which is marked as failed
let secondTestCase = 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 tests="2" failures="1" errors="0" skipped="0">
<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:
// Each builder produces a single report file
let anotherBuilder = builder.newBuilder();
CommonJS is also supported:
let builder = require('junit-report-builder');
Please refer to the e2e.spec.ts for more details on the usage.
index.d.ts. Thanks to Harel Mazor and Simeon Cheeseman.file attribute to a test case. Thanks to Ben Holland.Thanks to Robert Turner.
date-format to be a dependency. Previously it was incorrectly set to be a devDependency. Thanks to georgecrawford.© 2010 - cnpmjs.org x YWFE | Home | YWFE