Skip to content

Commit

Permalink
fix(reporter.teamcity): report spec names and proper browser name
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtajina committed Mar 13, 2013
1 parent 1be1ae1 commit c8f6f5e
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions lib/reporters/Teamcity.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ var escTCString = function (message) {
};

var getTestName = function (result) {
return result.slice(1).join(' ');
return result.description;
};

var getSuiteName = function(result) {
return result.suite.join(' ');
};


var TeamcityReporter = function(formatError, reportSlow) {
BaseReporter.call(this, formatError, reportSlow);

Expand All @@ -37,7 +42,7 @@ var TeamcityReporter = function(formatError, reportSlow) {

this.specSuccess = function(browser, result) {
var browseResult = this.checkNewSuit(browser, result);
var testName = getTestName(result.suite);
var testName = getTestName(result);

browseResult.log.push(util.format(this.TEST_START, escTCString(testName)));
browseResult.log.push(util.format(this.TEST_END,
Expand All @@ -46,7 +51,7 @@ var TeamcityReporter = function(formatError, reportSlow) {

this.specFailure = function(browser, result) {
var browseResult = this.checkNewSuit(browser, result);
var testName = getTestName(result.suite);
var testName = getTestName(result);

browseResult.log.push(util.format(this.TEST_START, escTCString(testName)));
browseResult.log.push(util.format(this.TEST_FAILED, escTCString(testName),
Expand All @@ -57,29 +62,31 @@ var TeamcityReporter = function(formatError, reportSlow) {

this.specSkipped = function(browser, result) {
var browseResult = this.checkNewSuit(browser, result);
var testName = getTestName(result.suite);
var testName = getTestName(result);

browseResult.log.push(util.format(this.TEST_IGNORED, escTCString(testName)));
};

this.checkNewSuit = function(browser, result) {
var browserResult = this.checkNewBrowser(browser);
var suiteExists = browserResult.suits.indexOf(result.suite[0]) !== -1;
var suiteName = getSuiteName(result);
var suiteExists = browserResult.suits.indexOf(suiteName) !== -1;

if(!suiteExists) {
if(browserResult.suits.length > 0) {
browserResult.log.push(util.format(this.SUITE_END,
escTCString(browserResult.suits[browserResult.suits.length - 1])));
}
browserResult.suits.push(result.suite[0]);
browserResult.log.push(util.format(this.SUITE_START, escTCString(result.suite[0])));
browserResult.suits.push(suiteName);
browserResult.log.push(util.format(this.SUITE_START, escTCString(suiteName)));
}
return browserResult;
};

this.checkNewBrowser = function(browser) {
if(!this.browserResults[browser.id]) {
this.browserResults[browser.id] = {
name: browser.name,
log : [],
suits : []
};
Expand All @@ -90,15 +97,15 @@ var TeamcityReporter = function(formatError, reportSlow) {
this.onRunComplete = function(browsers, results) {
var self = this;

Object.keys(this.browserResults).forEach(function(key) {
var browserResult = self.browserResults[key];
Object.keys(this.browserResults).forEach(function(browserId) {
var browserResult = self.browserResults[browserId];
if(browserResult.suits.length > 0) {
browserResult.log.push(util.format(self.SUITE_END,
escTCString(browserResult.suits[browserResult.suits.length - 1])));
}
self.write(self.BROWSER_START, key);
self.write(self.BROWSER_START, browserResult.name);
self.write(browserResult.log.join('\n'));
self.write(self.BROWSER_END, key);
self.write(self.BROWSER_END, browserResult.name);
});

this.writeCommonMsg(browsers.map(this.renderBrowser).join('\n') + '\n');
Expand Down

0 comments on commit c8f6f5e

Please sign in to comment.