davidparsson / junit-report-builder

Making it easier to build Jenkins compatible JUnit XML reports
MIT License
21 stars 14 forks source link
javascript jenkins junit-report nodejs

junit-report-builder

Build Status Weekly Downloads

A project aimed at making it easier to build Jenkins compatible XML based JUnit reports.

Installation

To install the latest version, run:

npm install junit-report-builder --save

Usage

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 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:

builder = builder.newBuilder();

Please refer to the e2e.spec.ts for more details on the usage.

License

MIT

Changelog

4.1.0

4.0.0

3.2.1

3.2.0

3.1.0

3.0.1

3.0.0

2.1.0

2.0.0

1.3.3

1.3.2

Thanks to Robert Turner.

1.3.1

1.3.0

1.2.0

1.1.1

1.1.0

1.0.0

0.0.2

0.0.1