Skip to content

Commit

Permalink
Merge pull request #48 from infosupport/log-failed-test
Browse files Browse the repository at this point in the history
  • Loading branch information
simondel committed Mar 17, 2016
2 parents 80429c6 + 871e1e1 commit e24b49e
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/Stryker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ export default class Stryker {
*/
runMutationTest(cb: () => void) {
console.log('INFO: Running initial test run');
this.testRunnerOrchestrator.recordCoverage().then((runResults) => {
if (this.allTestsSuccessful(runResults)) {
this.testRunnerOrchestrator.recordCoverage().then((runResults) => {
let unsuccessfulTests = runResults.filter((runResult: RunResult) => {
return !(runResult.failed === 0 && runResult.result === TestResult.Complete);
});
if (unsuccessfulTests.length === 0) {
console.log('INFO: Initial test run succeeded');
console.log(runResults);

Expand All @@ -85,7 +88,7 @@ export default class Stryker {
cb();
});
} else {
console.log('ERROR: One or more tests failed in the inial test run!');
this.logFailedTests(unsuccessfulTests);
}
});

Expand Down Expand Up @@ -130,12 +133,21 @@ export default class Stryker {
* @param {RunResult[]} runResults - The list of RunResults.
* @returns {Boolean} True if all tests passed.
*/
private allTestsSuccessful(runResults: RunResult[]): boolean {
var unsuccessfulTest = _.find(runResults, (runResult: RunResult) => {
return !(runResult.failed === 0 && runResult.result === TestResult.Complete);
private logFailedTests(unsuccessfulTests: RunResult[]): void {
let specNames: string[] = [];
unsuccessfulTests.forEach(runResult => {
runResult.specNames.forEach(specName => {
if (specNames.indexOf(specName) < 0) {
specNames.push(specName);
}
});
});
return _.isUndefined(unsuccessfulTest);
};

console.log('ERROR: One or more tests failed in the inial test run:');
specNames.forEach(filename => {
console.log('\t', filename);
});
}
}
(function run() {
function list(val: string) {
Expand Down

0 comments on commit e24b49e

Please sign in to comment.