Added the relevant code from the JUnitDataReporter into the PhantomReporter for use from within the Phantom environment
This commit is contained in:
parent
0313861501
commit
a6fd38da1b
@ -40,6 +40,7 @@
|
||||
};
|
||||
|
||||
PhantomReporter.prototype.reportSpecStarting = function(spec) {
|
||||
spec.startTime = (new Date()).getTime();
|
||||
var message = {
|
||||
suite : {
|
||||
description : spec.suite.description
|
||||
@ -84,10 +85,13 @@
|
||||
var specIds = runner.specs().map(function(a){return a.id;});
|
||||
var summary = this.resultsForSpecs(specIds);
|
||||
phantom.sendMessage('jasmine.reportRunnerResults',summary);
|
||||
phantom.sendMessage('jasmine.reportJUnitResults', this.generateJUnitSummary_(runner));
|
||||
phantom.sendMessage('jasmine.done.PhantomReporter');
|
||||
};
|
||||
|
||||
PhantomReporter.prototype.reportSuiteResults = function(suite) {
|
||||
suite.timestamp = new Date();
|
||||
suite.duration = suite.timestamp.getTime() - suite.specs()[0].startTime;
|
||||
phantom.sendMessage('jasmine.reportSuiteResults',{
|
||||
description : suite.description,
|
||||
results : suite.results()
|
||||
@ -130,6 +134,7 @@
|
||||
}
|
||||
|
||||
PhantomReporter.prototype.reportSpecResults = function(spec) {
|
||||
spec.duration = (new Date()).getTime() - spec.startTime;
|
||||
var _results = spec.results();
|
||||
var results = {
|
||||
description : _results.description,
|
||||
@ -189,5 +194,56 @@
|
||||
};
|
||||
};
|
||||
|
||||
function getNestedSuiteName(suite)
|
||||
{
|
||||
var names = [];
|
||||
while (suite) {
|
||||
names.unshift(suite.description);
|
||||
suite = suite.parentSuite;
|
||||
}
|
||||
return names.join(' ');
|
||||
}
|
||||
|
||||
PhantomReporter.prototype.generateJUnitSummary_ = function(runner) {
|
||||
return runner.suites().map(
|
||||
function(suite)
|
||||
{
|
||||
var failures = 0,
|
||||
data = {
|
||||
name: getNestedSuiteName(suite),
|
||||
time: suite.duration,
|
||||
timestamp: suite.timestamp,
|
||||
tests: suite.specs().length,
|
||||
errors: 0, // TODO: These exist in the JUnit XML but not sure how they map to jasmine things
|
||||
testcases: suite.specs().map(
|
||||
function(spec)
|
||||
{
|
||||
var failureMessages = [];
|
||||
if (spec.results().failedCount) {
|
||||
failures ++;
|
||||
spec.results().items_.forEach(
|
||||
function(expectation)
|
||||
{
|
||||
if (!expectation.passed()) {
|
||||
failureMessages.push((failureMessages.length + 1) + ': ' + expectation.message);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return {
|
||||
className: getNestedSuiteName(spec.suite),
|
||||
name: spec.description,
|
||||
time: spec.duration,
|
||||
failureMessage: failureMessages.join(' ')
|
||||
};
|
||||
}
|
||||
)
|
||||
};
|
||||
data.failures = failures;
|
||||
return data;
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
jasmine.getEnv().addReporter( new PhantomReporter() );
|
||||
}());
|
||||
|
Loading…
Reference in New Issue
Block a user