webdriverio/wdio-junit-reporter

Name: wdio-junit-reporter

Owner: WebdriverIO

Description: A WebdriverIO plugin. Report results in junit xml format.

Created: 2015-09-19 17:42:25.0

Updated: 2017-12-27 14:22:02.0

Pushed: 2018-01-18 17:45:12.0

Homepage: http://webdriver.io

Size: 79

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

WDIO JUnit Reporter

Build Status Code Climate Test Coverage dependencies Status


A WebdriverIO plugin. Report results in junit xml format.

WDIO JUnit Reporter

Installation

The easiest way is to keep wdio-junit-reporter as a devDependency in your package.json.


evDependencies": {
"wdio-junit-reporter": "~0.3.0"


You can simple do it by:

install wdio-junit-reporter --save-dev

Instructions on how to install WebdriverIO can be found here.

Configuration

Following code shows the default wdio test runner configuration. Just add 'junit' as reporter to the array. To get some output during the test you can run the WDIO Dot Reporter and the WDIO JUnit Reporter at the same time:

dio.conf.js
le.exports = {
// ...
reporters: ['dot', 'junit'],
reporterOptions: {
    junit: {
        outputDir: './',
        outputFileFormat: function(opts) { // optional
            return `results-${opts.cid}.${opts.capabilities}.xml`
        }
    }
},
// ...

The following options are supported:

outputDir

Define a directory where your xml files should get stored.

Type: String
Required

outputFileFormat

Define the format of your xml files using an opts parameter that contains the runner id as well as the capabilities of the runner.

Type: Function
Default:

utFileFormat: function(opts) { // optional
return `WDIO.xunit.${opts.capabilities}.${cid}.xml`

suiteNameFormat

Gives the ability to provide custom regex for formatting test suite name (e.g. in output xml ).

Type: Regex,
Default: /[^a-z0-9]+/

packageName

You can break out packages by an additional level by setting 'packageName'. For example, if you wanted to iterate over a test suite with different environment variable set:

Type: String
Example:

dio.conf.js
le.exports = {
// ...
reporters: ['dot', 'junit'],
reporterOptions: {
    junit: {
        outputDir: './',
        packageName: process.env.USER_ROLE // chrome.41 - administrator
    }
}
// ...

Jenkins Setup

Last but not least you nead to tell your CI job (e.g. Jenkins) where it can find the xml file. To do that add a post-build action to your job that gets executed after the test has run and point Jenkins (or your desired CI system) to your XML test results:

Point Jenkins to XML files

If there is no such post-build step in your CI system there is probably a plugin for that somewhere on the internet.

Development

All commands can be found in the package.json. The most important are:

Watch changes:

m run watch

Run tests:

m test

n test with coverage report:
m run test:cover

Build package:

m build

For more information on WebdriverIO see the homepage.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.