question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Offer source level fine grained control of mutations and mutators

See original GitHub issue

Is your feature request related to a problem? Please describe. Controlling mutations and mutators within the tested project source code for fine grained control. Proposed syntax looks like this

// Stryker disable once all : Mutation has been reviewed and cannot be killed

Somer users want to keep their mutation coverage at 100%. But Stryker.Net may generates mutation that cannot be killed due to some external dependencies or (user project) internal design choices. Users looking for 100% coverage want to be able to review those mutations and somehow mark them as to be ignored. From a practical perspective, the best place to flag those mutations as to be ignored is within the source code itself, using single line comments to give instructions

Describe the solution you’d like I also like the syntax. But it is somewhat different from the JS proposal (next which does not really makes to me). Assuming this difference an issue, I think I could implement this, here are the envisioned specs:

  • works on whole statements at minimum: this is due to how Roslyn attaches comments and code. Will do finer grained control (e.g. expression) if possible, but not a priority
  • works on unitary/automatic scope as a priority, manually defined scope (i.e using disable and restore) is a secondary objective. This derives from the assumption this feature should be used sparingly and not in broad strokes.
  • mutations will still be generated but will be flagged as ignored. First implementations may simply skip generating mutations. Remark: skipping mutating altogether may provide a workaround for when a mutator triggers an exception blocking all usage of Stryker ⇒ we need to choose which behavior we want.
  • works at statement, block or declaration level. The rule then apply to the attached scope. eg
{
  // Stryker disable once all
  int x = 2+2;
  int y = x+3;
}

⇒ disable mutation for int x = 2+2;

// Stryker disable once all
{
 int x = 2+2;
 int y = x+3;
}

⇒ disable mutation for both lines

  • manual defined scope (i.e using disable and restore) does not work across scope (i.e. you cannot disable mutations in one method and reenable it somewhere in the next method). This is due to the tree parsing logic we use which makes this needlessly difficult to implement; plus it should be used sparingly
  • full comment syntax should be // Stryker [disable[| once]|restore] [all|mutator1[|,mutator2...]][| : reason for disabling] the 'reason for disabling will be used to comment skipped mutations (assuming mutations are stil generated, see above) ⇒ we need to decide if we want to make this part mandatory or not. I am in favor of making it mandatory
  • Stryker could still generates mutations in diff-mode when the lines in the scope were mutated, giving an opportunity to review those lines. Note this probably means significant effort, as it means accessing diff information during mutation phase. Probably a feature for a future version, if possible at all.
  • Stryker could issue a warning, or block altogether if ratio of skipped mutants is above a user defined threshold. This may be useful for teams to control overall discipline with the feature.

Describe alternatives you’ve considered No better alternative identified. Potential candidates:

  • keeping some mutation database along with the project: requires extra work + difficult to properly identify mutants across project version
  • extending options syntax, such as providing the list of lines to be ignored (eg class.cs: 35-37, 52-56). Cumbersome to maintain as there is a chance of line numbers having to be changed following some refactoring. May push user to disable file entirely to avoid this maintenance burden
  • restricting mutators to ensure no un killable mutants can be generated: may lead to needlessly limit mutators because they may generate undue survivors. Plus, there still would be situation were a mutant could logically be killed, but can’t for practical reason (e.g : providing a callback to some external library the user has no control over)

Additional context Check discussion #1503 for further context and opinions

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
rouke-broersmacommented, May 28, 2021

I propose we simply disallow multiline comments and mixed inline comments. Only normal comments are allowed and they must be on their own line.

If someone really wants to disable part of a statement or expression mutation they can use the ugly example which works and is imo very clear in showing that something funky is going on there.

1reaction
psfinakicommented, Jun 1, 2021

OK, you convinced me with not requiring a comment 😃

As for once vs next, I slightly tilt to once, it clearly means “one case”, whereas next could refer to some next lines. There is also “ad hoc” expression, but it adds a bit different vibe probably.

Read more comments on GitHub >

github_iconTop Results From Across the Web

An intro to Mutation Testing - or why coverage sucks
A intro to Mutation Testing, a technique that has become robust enough ... If you want a more fine grained control, there are...
Read more >
Announcing Stryker.NET 1.0
It's now possible to filter mutants at the source code level using ... The ignore-mutations option now offers more fine-grained control.
Read more >
DeepMutation: Mutation Testing of Deep Learning Systems
In this paper, we propose a mutation testing framework specialized for DL systems to measure the quality of test data. To do this,...
Read more >
How to Use GraphQL Subscriptions to Build Real-Time ...
GraphQL subscriptions enable publishing updates to data in real time to subscribed clients. They are invoked in response to a mutation or change...
Read more >
Gambit: An Open Source Mutation Generator for Solidity
As the documentation shows, Gambit offers users fine-grained control over what contracts and functions to mutate. This helps reduce the generation of unhelpful ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found