Skip to content

Commit

Permalink
fix(reporter.junit): Add browser log output to JUnit.xml
Browse files Browse the repository at this point in the history
Make the JUnit adapter inherit from base
Push all log message into system-out element of the junit xml file.

Closes #302
  • Loading branch information
bitwiseman authored and vojtajina committed Feb 21, 2013
1 parent 47d399a commit f108799
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/reporters/JUnit.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@ var path = require('path');
var fs = require('fs');
var builder = require('xmlbuilder');

var BaseReporter = require('./Base');
var helper = require('../helper');
var log = require('../logger').create('reporter');


var JUnitReporter = function(formatError, outputFile, pkgName, emitter) {
var messageAdapter = function(msg) {
allMessages.push(msg);
};

BaseReporter.call(this, formatError, 0, messageAdapter);

var xml;
var suites;
var pendingFileWritings = 0;
var fileWritingFinished = function() {};

this.adapters = [];
var allMessages = [];

this.onRunStart = function(browsers) {
suites = {};
Expand All @@ -38,7 +44,7 @@ var JUnitReporter = function(formatError, outputFile, pkgName, emitter) {
suite.att('failures', result.failed);
suite.att('time', result.netTime / 1000);

suite.ele('system-out');
suite.ele('system-out').dat(allMessages.join() + '\n');
suite.ele('system-err');
};

Expand All @@ -63,7 +69,7 @@ var JUnitReporter = function(formatError, outputFile, pkgName, emitter) {
suites = xml = null;
};

this.onSpecComplete = function(browser, result) {
this.specSuccess = this.specSkipped = this.specFailure = function(browser, result) {
var spec = suites[browser.id].ele('testcase', {
name: result.description, time: result.time / 1000,
classname: (pkgName ? pkgName + ' ' : '') + browser.name + '.' + result.suite.join(' ').replace(/\./g, '_')
Expand Down

0 comments on commit f108799

Please sign in to comment.