Comparing version 0.19.4 to 0.20.0
@@ -6,2 +6,13 @@ # Change Log | ||
<a name="0.20.0"></a> | ||
# [0.20.0](https://github.com/stryker-mutator/stryker/compare/stryker@0.19.4...stryker@0.20.0) (2018-03-22) | ||
### Features | ||
* **stryker:** add excludedMutations as a config option ([#13](https://github.com/stryker-mutator/stryker/issues/13)) ([#652](https://github.com/stryker-mutator/stryker/issues/652)) ([cc8a5f1](https://github.com/stryker-mutator/stryker/commit/cc8a5f1)) | ||
<a name="0.19.4"></a> | ||
@@ -8,0 +19,0 @@ ## [0.19.4](https://github.com/stryker-mutator/stryker/compare/stryker@0.19.3...stryker@0.19.4) (2018-03-21) |
{ | ||
"name": "stryker", | ||
"version": "0.19.4", | ||
"version": "0.20.0", | ||
"description": "The extendable JavaScript mutation testing framework", | ||
@@ -82,3 +82,3 @@ "main": "src/Stryker.js", | ||
"@types/progress": "^2.0.1", | ||
"stryker-api": "^0.13.1" | ||
"stryker-api": "^0.14.0" | ||
}, | ||
@@ -85,0 +85,0 @@ "peerDependencies": { |
@@ -167,8 +167,18 @@ [![Build Status](https://travis-ci.org/stryker-mutator/stryker.svg?branch=master)](https://travis-ci.org/stryker-mutator/stryker) | ||
#### Mutator | ||
**Config file:** `mutator: 'es5'` | ||
**Command line:** `--mutator es5` | ||
**Config file:** `mutator: { name: 'es5', excludedMutations: ['BooleanSubstitution', 'StringLiteral'] }` | ||
**Default value:** `es5` | ||
**Mandatory**: no | ||
**Description:** | ||
With `mutator` you configure which mutator plugin you want to use. This defaults to es5. | ||
With `mutator` you configure which mutator plugin you want to use, and optionally, which mutation types to exclude from the test run. | ||
The mutator plugin name defaults to `es5` if not specified. The list of excluded mutation types defaults to an empty array, meaning all mutation types will be included in the test. | ||
The full list of mutation types varies slightly between mutators (for example, the `es5` mutator will not use the same mutation types as the `typescript` mutator). Mutation type names are case-sensitive, and can be found either in the source code or in a generated Stryker report. | ||
When using the command line, only the mutator name as a string may be provided. | ||
When using the config file, you can provide either a string representing the mutator name, or a `MutatorDescriptor` object, like so: | ||
* `MutatorDescriptor` object: `{ name: 'name', excludedMutations: ['mutationType1', 'mutationType2', ...] }`: | ||
* The `name` property is mandatory and contains the name of the mutator plugin to use. | ||
* The `excludedMutations` property is mandatory and contains the types of mutations to exclude from the test run. | ||
#### Transpilers | ||
@@ -175,0 +185,0 @@ **Config file:** `transpilers: '['typescript']'` |
@@ -11,2 +11,3 @@ import { TestFramework } from 'stryker-api/test_framework'; | ||
private validateTestFramework(); | ||
private validateMutator(); | ||
private validateThresholds(); | ||
@@ -13,0 +14,0 @@ private validateThresholdValue(name, value); |
@@ -14,2 +14,3 @@ "use strict"; | ||
this.validateThresholds(); | ||
this.validateMutator(); | ||
this.validateLogLevel(); | ||
@@ -19,3 +20,2 @@ this.validateTimeout(); | ||
this.validateIsNumber('maxConcurrentTestRunners', this.strykerConfig.maxConcurrentTestRunners); | ||
this.validateIsString('mutator', this.strykerConfig.mutator); | ||
this.validateIsStringArray('plugins', this.strykerConfig.plugins); | ||
@@ -33,2 +33,13 @@ this.validateIsStringArray('reporter', this.strykerConfig.reporter); | ||
}; | ||
ConfigValidator.prototype.validateMutator = function () { | ||
var mutator = this.strykerConfig.mutator; | ||
if (typeof mutator === 'object') { | ||
var mutatorDescriptor = mutator; | ||
this.validateIsString('mutator.name', mutatorDescriptor.name); | ||
this.validateIsStringArray('mutator.excludedMutations', mutatorDescriptor.excludedMutations); | ||
} | ||
else if (typeof mutator !== 'string') { | ||
this.invalidate("Value \"" + mutator + "\" is invalid for `mutator`. Expected either a string or an object"); | ||
} | ||
}; | ||
ConfigValidator.prototype.validateThresholds = function () { | ||
@@ -35,0 +46,0 @@ var thresholds = this.strykerConfig.thresholds; |
@@ -8,2 +8,3 @@ import { File } from 'stryker-api/core'; | ||
mutate(inputFiles: File[]): Mutant[]; | ||
private getMutatorName(mutator); | ||
} |
@@ -12,5 +12,13 @@ "use strict"; | ||
return mutant_1.MutatorFactory.instance() | ||
.create(this.config.mutator, this.config) | ||
.create(this.getMutatorName(this.config.mutator), this.config) | ||
.mutate(inputFiles); | ||
}; | ||
MutatorFacade.prototype.getMutatorName = function (mutator) { | ||
if (typeof mutator === 'string') { | ||
return mutator; | ||
} | ||
else { | ||
return mutator.name; | ||
} | ||
}; | ||
return MutatorFacade; | ||
@@ -17,0 +25,0 @@ }()); |
@@ -18,2 +18,4 @@ import { Config } from 'stryker-api/config'; | ||
private mutate(inputFiles, initialTestRunResult); | ||
private logMutantCount(includedMutantCount, totalMutantCount); | ||
private removeExcludedMutants(mutants); | ||
private loadPlugins(); | ||
@@ -20,0 +22,0 @@ private wrapUpReporter(); |
@@ -82,12 +82,31 @@ "use strict"; | ||
var mutator = new MutatorFacade_1.default(this.config); | ||
var mutants = mutator.mutate(inputFiles); | ||
if (mutants.length) { | ||
this.log.info(mutants.length + " Mutant(s) generated"); | ||
var allMutants = mutator.mutate(inputFiles); | ||
var includedMutants = this.removeExcludedMutants(allMutants); | ||
this.logMutantCount(includedMutants.length, allMutants.length); | ||
var mutantRunResultMatcher = new MutantTestMatcher_1.default(includedMutants, inputFiles, initialTestRunResult.runResult, SourceMapper_1.default.create(initialTestRunResult.transpiledFiles, this.config), initialTestRunResult.coverageMaps, this.config, this.reporter); | ||
return mutantRunResultMatcher.matchWithMutants(); | ||
}; | ||
Stryker.prototype.logMutantCount = function (includedMutantCount, totalMutantCount) { | ||
var mutantCountMessage; | ||
if (includedMutantCount) { | ||
mutantCountMessage = includedMutantCount + " Mutant(s) generated"; | ||
} | ||
else { | ||
this.log.info('It\'s a mutant-free world, nothing to test.'); | ||
mutantCountMessage = "It's a mutant-free world, nothing to test."; | ||
} | ||
var mutantRunResultMatcher = new MutantTestMatcher_1.default(mutants, inputFiles, initialTestRunResult.runResult, SourceMapper_1.default.create(initialTestRunResult.transpiledFiles, this.config), initialTestRunResult.coverageMaps, this.config, this.reporter); | ||
return mutantRunResultMatcher.matchWithMutants(); | ||
var numberExcluded = totalMutantCount - includedMutantCount; | ||
if (numberExcluded) { | ||
mutantCountMessage += " (" + numberExcluded + " Mutant(s) excluded)"; | ||
} | ||
this.log.info(mutantCountMessage); | ||
}; | ||
Stryker.prototype.removeExcludedMutants = function (mutants) { | ||
if (typeof this.config.mutator === 'string') { | ||
return mutants; | ||
} | ||
else { | ||
var mutatorDescriptor_1 = this.config.mutator; | ||
return mutants.filter(function (mutant) { return mutatorDescriptor_1.excludedMutations.indexOf(mutant.mutatorName) === -1; }); | ||
} | ||
}; | ||
Stryker.prototype.loadPlugins = function () { | ||
@@ -94,0 +113,0 @@ if (this.config.plugins) { |
343631
6361
302