Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
id: '13',
location: null,
mutatedLines: 'string',
mutatorName: 'string',
originalLines: 'string',
range: [1, 2],
replacement: 'string',
sourceFilePath: 'string',
status: MutantStatus.TimedOut,
testsRan: ['']
};
const allReporter = new AllReporter();
allReporter.onMutantTested(result);
console.log(result);
console.log(
`Mutant status runtime error: ${MutantStatus[MutantStatus.RuntimeError]}`
);
console.log(
`Mutant status transpile error: ${MutantStatus[MutantStatus.TranspileError]}`
);
const matchedMutant: MatchedMutant = {
fileName: 'string',
id: '13',
mutatorName: '',
replacement: 'string',
scopedTestIds: [52],
timeSpentScopedTests: 52,
runAllTests: false,
};
allReporter.onAllMutantsMatchedWithTests([Object.freeze(matchedMutant)]);
private determineMutantState(runResult: RunResult): MutantStatus {
switch (runResult.status) {
case RunStatus.Timeout:
return MutantStatus.TimedOut;
case RunStatus.Error:
return MutantStatus.RuntimeError;
case RunStatus.Complete:
if (runResult.tests.some(t => t.status === TestStatus.Failed)) {
return MutantStatus.Killed;
} else {
return MutantStatus.Survived;
}
}
}
<input type="checkbox" value="{state.toString()}" checked="{isChecked}" class="form-check-input stryker-display">
{MutantStatus[state]} {`(${filtered.length})`}
;
} else {
return '';
}
}
return <div class="row legend">
<form novalidate="novalidate" class="col-md-12">
{displayCheckbox(MutantStatus.NoCoverage, true)}
{displayCheckbox(MutantStatus.Survived, true)}
{displayCheckbox(MutantStatus.Killed, false)}
{displayCheckbox(MutantStatus.TimedOut, false)}
{displayCheckbox(MutantStatus.RuntimeError, false)}
{displayCheckbox(MutantStatus.TranspileError, false)}
<a class="stryker-collapse-expand-all" href="#">Expand all</a>
</form>
</div>;
}
private collectMutantResult(mutant: TestableMutant, runResult: RunResult): MutantResult {
const status: MutantStatus = this.determineMutantState(runResult);
const testNames = runResult.tests.filter(t => t.status !== TestStatus.Skipped).map(t => t.name);
if (this.log.isDebugEnabled() && status === MutantStatus.RuntimeError) {
const error = runResult.errorMessages ? runResult.errorMessages.toString() : '(undefined)';
this.log.debug('A runtime error occurred: %s during execution of mutant: %s', error, mutant.toString());
}
return mutant.createResult(status, testNames);
}
private countNumbers(mutantResults: MutantResult[]) {
const count = (mutantResult: MutantStatus) => mutantResults.filter(_ => _.status === mutantResult).length;
const killed = count(MutantStatus.Killed);
const timedOut = count(MutantStatus.TimedOut);
const survived = count(MutantStatus.Survived);
const noCoverage = count(MutantStatus.NoCoverage);
const runtimeErrors = count(MutantStatus.RuntimeError);
const transpileErrors = count(MutantStatus.TranspileError);
const totalDetected = timedOut + killed;
const totalUndetected = survived + noCoverage;
const totalCovered = totalDetected + survived;
const totalValid = totalUndetected + totalDetected;
const totalInvalid = runtimeErrors + transpileErrors;
const totalMutants = totalValid + totalInvalid;
const mutationScore = totalValid > 0 ? (totalDetected / totalValid) * 100 : defaultScoreIfNoValidMutants;
const mutationScoreBasedOnCoveredCode = totalValid > 0 ? (totalDetected / totalCovered) * 100 || 0 : defaultScoreIfNoValidMutants;
return {
killed,
mutationScore,
mutationScoreBasedOnCoveredCode,
noCoverage,
runtimeErrors,
survived,
mutantResults.forEach((result, index) => {
if (result.testsRan) {
totalTests += result.testsRan.length;
}
switch (result.status) {
case MutantStatus.Killed:
this.log.debug(chalk.bold.green('Mutant killed!'));
this.logMutantResult(result, index, logDebugFn);
break;
case MutantStatus.TimedOut:
this.log.debug(chalk.bold.yellow('Mutant timed out!'));
this.logMutantResult(result, index, logDebugFn);
break;
case MutantStatus.RuntimeError:
this.log.debug(chalk.bold.yellow('Mutant caused a runtime error!'));
this.logMutantResult(result, index, logDebugFn);
break;
case MutantStatus.TranspileError:
this.log.debug(chalk.bold.yellow('Mutant caused a transpile error!'));
this.logMutantResult(result, index, logDebugFn);
break;
case MutantStatus.Survived:
this.logMutantResult(result, index, writeLineFn);
break;
case MutantStatus.NoCoverage:
this.logMutantResult(result, index, writeLineFn);
break;
}
});
this.writeLine(`Ran ${(totalTests / mutantResults.length).toFixed(2)} tests per mutant on average.`);
function getContextClassForStatus(status: MutantStatus) {
switch (status) {
case MutantStatus.Killed:
return 'success';
case MutantStatus.NoCoverage:
case MutantStatus.Survived:
return 'danger';
case MutantStatus.TimedOut:
return 'warning';
case MutantStatus.RuntimeError:
case MutantStatus.TranspileError:
return 'secondary';
}
}
private toStatus(status: MutantStatus): mutationTestReportSchema.MutantStatus {
switch (status) {
case MutantStatus.Killed:
return mutationTestReportSchema.MutantStatus.Killed;
case MutantStatus.NoCoverage:
return mutationTestReportSchema.MutantStatus.NoCoverage;
case MutantStatus.RuntimeError:
return mutationTestReportSchema.MutantStatus.RuntimeError;
case MutantStatus.Survived:
return mutationTestReportSchema.MutantStatus.Survived;
case MutantStatus.TimedOut:
return mutationTestReportSchema.MutantStatus.Timeout;
case MutantStatus.TranspileError:
return mutationTestReportSchema.MutantStatus.CompileError;
default:
this.logUnsupportedMutantStatus(status);
return mutationTestReportSchema.MutantStatus.RuntimeError;
}
}