-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exclude mutation types #13
Comments
This feature request seems to be a duplicate of #293. |
I wonder if it makes sense to exclude/disable/enable mutation types by a system similar to the rules configuration of tslint (See https://palantir.github.io/tslint/usage/configuration/) Example: {
mutations: {
StringLiteral: false,
Block: false
}
} Th advantage of this system
Example: {
mutations: {
StringLiteral: {
relaceExportedConst: false,
replacements: ["", "<script>window.alert('Evil Hack!')</script>"]
},
}
} |
@simondel @nicojs Is there any ongoing work in the direction of this ticket? Otherwise I would like to volunteer to implement it, at least for the TypescriptMutator. For me it seems that in the current design, the class TypescriptMutator is responsible for knowing all typescript "child" mutators and for executing them. In the long run, it might be better to do this work on a higher level, but I'm particular interested in TypeScript and it could be a good start. |
There are plans to implement this, but it's not at the top of our todo-list. I would be a fan of working with a blacklist that you could set in your config. That way when we release a new mutation type, you will actually start using it. Perhaps we could simply work with an array property that is added to the config:
The names of the excluded mutations should be exactly the same (case and all) with the reported value: The constructor you found is used for test purposes. A more solid option might be to filter the @nicojs What you think? PS why is the |
@simondel So you mean to filter in https://github.com/stryker-mutator/stryker/blob/5dd8be70f0ec53152837abae6145214b9d06d364/packages/stryker/src/Stryker.ts#L70 Advantages:
Drawbacks:
Advantages/Drawback:
So your approach has many advantages, but I have to add that my approach could also work as a blacklist (If a mutation is not listed in mutations: {}, it's enabled by default.). |
I actually meant filtering inside the mutate function in a mutator, but filtering in Stryker would not even be a bad idea! I'm just not a big fan of doing a whole lot of magic in a constructor. |
Agreed. It has a big advantage as we would only have to implement it once for all current and future mutators. Generating mutants only takes a fraction of the total mutation testing time, so it's not a big performance hit to first generate all mutants. I also like the idea of logging how many mutants are ignored based on your configuration. Let's proceed with this approach.
@shybyte that's awesome! The floor is yours! If you need any help, don't hesitate to ask.
I like this approach. It looks clean and leaves room for more configuration, like @shybyte said. All mutators are enabled at the start, so it will effectively be a black list for now. Later on we could introduce new mutators with default enabled = false for performance reasons (PIT also takes this approach). @simondel would you also agree with this? |
Let's do it! |
@simondel @nicojs How should the new config property be named??
??? |
Yeah it's quite confusing. I'd say we go with |
@simondel Your comment raises again the question if we implement the
approach??? @nicojs What do you think? |
I've got an idea. How about we allow this configuration: {
mutator: {
kind: 'typescript',
mutations: {
block: false,
stringLiteral: { // example of a future config
replaceExportedConst: false,
replacements: ["", "<script>window.alert('Evil Hack!')</script>"]
}
} I think the intent here looks really clear. You would still be able to just put the kind as string as well: |
…tor#13) This adds the ability to exclude specific mutation types ('BooleanSubstitution', 'ArrayLiteral', etc.) from being performed during the test run. Can be used via either command-line or config file. Defaults to an empty array, meaning all mutation types are used.
This adds the ability to exclude specific mutation types (`'BooleanSubstitution'`, `'ArrayLiteral'`, etc.) from being performed during the test run. Can be used via the config file. Defaults to an empty array, meaning all mutation types are used. Configuration: ```js mutator: { name: 'javascript', excludedMutations: [ 'BooleanSubstitution', 'Block' /*, ... */] } ```
Fixed with #652 |
It should be possible to configure which mutation types are and which aren't used. The importance of this feature increases as the number of mutation types increases.
The text was updated successfully, but these errors were encountered: