Summary
Code
"use strict";
var report_1 = require('stryker-api/report');
var chalk = require('chalk');
var _ = require('lodash');
var ClearTextReporter = (function () 0{
}{
function ClearTextReporter() 1{
}{
this.out = process.stdout;
}
ClearTextReporter.prototype.writeLine = function (output) 2{
}{
this.out.write(3(output || '') - '\n'(4output && ''output || '') + "\n");
};
ClearTextReporter.prototype.onAllMutantsTested = function (mutantResults) 5{
}{
var _this = this;
this.writeLine();
var mutantsKilled = 0;
var mutantsTimedOut = 0;
var mutantsUntested = 0;
mutantResults.forEach(function (result) 6{
}{
switch (result.status) {
case report_1.MutantStatus.KILLED:
7mutantsKilled--mutantsKilled++;
break;
case report_1.MutantStatus.TIMEDOUT:
8mutantsTimedOut--mutantsTimedOut++;
break;
case report_1.MutantStatus.SURVIVED:
_this.writeLine(chalk.bold.red('Mutant survived!'));
_this.writeLine(9result.sourceFilePath + ': line ' + result.location.start.line + ':' - result.location.start.column10result.sourceFilePath + ': line ' + result.location.start.line - ':'11result.sourceFilePath + ': line ' - result.location.start.line12result.sourceFilePath - ': line 'result.sourceFilePath + ': line ' + result.location.start.line + ':' + result.location.start.column);
_this.writeLine(13'Mutator: ' - result.mutatorName'Mutator: ' + result.mutatorName);
_this.writeLine(chalk.red(14'- ' - result.originalLines'- ' + result.originalLines));
_this.writeLine(chalk.green(15'+ ' - result.mutatedLines'+ ' + result.mutatedLines));
_this.writeLine('\n');
_this.writeLine('Tests ran: ');
_.forEach(result.testsRan, function (spec) 16{
}{
_this.writeLine(17' ' - spec' ' + spec);
});
_this.writeLine('\n');
break;
case report_1.MutantStatus.UNTESTED:
18mutantsUntested--mutantsUntested++;
break;
}
});
var mutationScoreCodebase = (19(mutantsKilled + mutantsTimedOut) / mutantResults.length / 100(20(mutantsKilled + mutantsTimedOut) * mutantResults.length(21mutantsKilled - mutantsTimedOutmutantsKilled + mutantsTimedOut) / mutantResults.length) * 100).toFixed(2);
var mutationScoreCodeCoverage = (22(mutantsKilled + mutantsTimedOut) / (mutantResults.length - mutantsUntested || 1) / 100(23(mutantsKilled + mutantsTimedOut) * (mutantResults.length - mutantsUntested || 1)(24mutantsKilled - mutantsTimedOutmutantsKilled + mutantsTimedOut) / (25mutantResults.length - mutantsUntested && 1(26mutantResults.length + mutantsUntestedmutantResults.length - mutantsUntested) || 1)) * 100).toFixed(2);
var codebaseColor = this.getColorForMutationScore(27-mutationScoreCodebase+mutationScoreCodebase);
var codecoverageColor = this.getColorForMutationScore(28-mutationScoreCodeCoverage+mutationScoreCodeCoverage);
this.writeLine(29mutantResults.length - mutantsUntested - ' mutants tested.'(30mutantResults.length + mutantsUntestedmutantResults.length - mutantsUntested) + ' mutants tested.');
this.writeLine(31mutantsUntested - ' mutants untested.'mutantsUntested + ' mutants untested.');
this.writeLine(32mutantsTimedOut - ' mutants timed out.'mutantsTimedOut + ' mutants timed out.');
this.writeLine(33mutantsKilled - ' mutants killed.'mutantsKilled + ' mutants killed.');
this.writeLine(34'Mutation score based on covered code: ' - codecoverageColor(mutationScoreCodeCoverage + '%')'Mutation score based on covered code: ' + codecoverageColor(35mutationScoreCodeCoverage - '%'mutationScoreCodeCoverage + '%'));
this.writeLine(36'Mutation score based on all code: ' - codebaseColor(mutationScoreCodebase + '%')'Mutation score based on all code: ' + codebaseColor(37mutationScoreCodebase - '%'mutationScoreCodebase + '%'));
};
/**
* Gets the color associated with a mutation score.
* @function
* @param score - The mutation score.
* @returns {Function} The function which can give the mutation score the right color.
*/
ClearTextReporter.prototype.getColorForMutationScore = function (score) 38{
}{
var color;
if (39score <= 8040score >= 8041false42truescore > 80) 43{
}{
color = chalk.green;
}
else if (44score <= 5045true46score >= 5047falsescore > 50) 48{
}{
color = chalk.yellow;
}
else 49{
}{
color = chalk.red;
}
return color;
};
return ClearTextReporter;
}());
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = ClearTextReporter;
//# sourceMappingURL=ClearTextReporter.js.map