-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Filter tests programatically #4183
Comments
@nicojs thank you for this issue, it sounds interesting to me. I would like to understand better the big picture and will need some time to clarify:
I don't understand this one. We have a |
@nicojs I don't really like Mocha's You would like to do the same, right? Load all unfiltered tests to the runner and re-use the same runner instance applying different filters.
|
No, it would basically work the same as
No. During mutation testing, we can't instrument/change the tests. They are what they are.
Sounds good. But that does seem #2783 also needs to be implemented.
It should run programmatically and should also work in the browser.
This isn't useful to us since we might not change the source files at all. Unless we would be able to trick the watch feature that files changed while they didn't? That doesn't sound like a good plan.
Yes, exactly. Let me clarify a bit better what the use case is, seeing as I think that would make it a lot clearer. During Mutation testing, you are testing the effectiveness of your tests by automatically inserting bugs (or mutants) into your production source code to see if they are spotted by the tests (i.e. result in a failing test). Take this example: // add.js
function add(a, b) {
return a + b;
}
// add.spec.js
it('should add two numbers', () => {
require('chai').expect(add(4, 0)).eq(4); // great test! ... well, maybe not so much
});
it('some other test', () => {
require('chai').expect(subtract(4, 0)).eq(4);
}); A mutation testing framework might instrument // add.js
function add(a, b) {
if(global.activeMutation === 0) {
return a - b;
} else {
global.mutantCoverage[0] ++;
return a + b;
}
} It will add something we call a "mutation switch". You can turn one mutation on/off at a time. So even though the source files don't change, the test result might very well, since the mutation testing framework decides what to turn on/off. (which is why #2783 is important) This is where the programmatic test filtering comes in. We want to be able to choose which tests to run in order to not run too many. In this example, if we want to test mutant 0, we don't want to run the second test ( I hope this clarifies it for you. Sorry it took me so long to respond. |
We no longer need this functionality, because Stryker 4 can work with the current |
Is your feature request related to a problem or a nice-to-have?? Please describe.
For the JavaScript mutation testing framework Stryker we want to be able to filter out individual tests programmatically. The
it.only
won't work in our case, we need to do it programmatically.Describe the solution you'd like
Something like Jasmine's
specFilter
would be awesome.Describe alternatives you've considered
Right now, we're using a horrible hack:
It works but has obvious drawbacks:
Additional context
I want to revisit #2605. Back in the day, @boneskull said this wouldn't be supported since there was no way to configure a
testFilter
function from the command line and there was no config file support.Since we now have
.mocharc.js
support the CLI would also able to support thetestFilter
:I'd be happy to see how I could help with this!
The text was updated successfully, but these errors were encountered: