Skip to content
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

Mutate expression bodied methods to empty body #2798

Open
NBlackout opened this issue Dec 14, 2023 · 5 comments
Open

Mutate expression bodied methods to empty body #2798

NBlackout opened this issue Dec 14, 2023 · 5 comments
Labels
Area: Mutator new mutators or change to existing one 🐛 Bug Something isn't working 🚀 Feature request New feature or request Priority: Medium Issues that have a workaround or but should be fixed

Comments

@NBlackout
Copy link

NBlackout commented Dec 14, 2023

Describe the bug
No statement removal mutant is being generated for expression-bodied methods (=> [...] instead of { [...] })

Logs
expression-body.zip
statement-body.zip

Expected behavior
I was expecting both method syntaxes to behave similarly for mutant detection/generation.
We use this expression-bodied syntax a lot for one-liner (props, methods, etc.) so this bug (or feature?) is quite important for us.
The workaround would be to force statement body everywhere in our solution, or at least for project under tests.

Desktop (please complete the following information):

  • OS: Windows
  • Type of project: .NET
  • Framework Version: 6.0
  • Stryker Version: 3.12.0

Additional context
Love mutation testing, love the tool, kudos !

@NBlackout NBlackout added the 🐛 Bug Something isn't working label Dec 14, 2023
@NBlackout
Copy link
Author

NBlackout commented Dec 14, 2023

This issue might be a duplicate of #134 (sorry I only checked for opened issues). I will read in detail its content 👀

@NBlackout
Copy link
Author

NBlackout commented Dec 14, 2023

From what I understood, ternary operators are properly handled thanks to #17 (which #134 is marked duplicate of, not sure why because issues were not exactly the same even though kinda related).
I would say expression-bodied syntax handling can still be improved.

I can provide more information if necessary, or even a simple project with both syntaxes 🙏

@NBlackout NBlackout changed the title Expression-bodied method syntax prevents mutant detection Expression-bodied method syntax prevents some mutant detection Dec 14, 2023
@dupdob
Copy link
Member

dupdob commented Dec 14, 2023

Yes, can you please provide more explicit expectations and/or source code/samples. That would help us provide more accurate answer.

  1. yes, there is no statement mutation for expression bodied method as those do not have any statement inside. We could either extend statement mutator to cover for his or add a new dedicated mutator (my favorite). Please note that different users have different expectations on what is a good mutator, so nothing is as obvious as one would like.
  2. it also affect block mutator: an expression body is not a block statement
  3. all other mutators are applied when relevant.

Hope this helps.

@NBlackout
Copy link
Author

Thanks for the feedback ! I'm preparing a sample 👍

@NBlackout
Copy link
Author

I can reproduce this issue even with a simple { return 3; } and => 3. You can run mutation test using the project under test launchSettings.json.
Please let me know if setup is incomplete and I will make sure to include more details.

Have a great day 😁

ExpressionBodiedMutationTests.zip

@dupdob dupdob added 🚀 Feature request New feature or request Priority: Medium Issues that have a workaround or but should be fixed Area: Mutator new mutators or change to existing one labels Dec 15, 2023
@dupdob dupdob changed the title Expression-bodied method syntax prevents some mutant detection Mutate expression bodied methods to empty body Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Mutator new mutators or change to existing one 🐛 Bug Something isn't working 🚀 Feature request New feature or request Priority: Medium Issues that have a workaround or but should be fixed
Projects
None yet
Development

No branches or pull requests

2 participants