/vscode-stryker-mutator

Unofficial VSCode extension of 'Stryker Mutator' for hunting mutants hiding in our codebase (currently, it supports .NET)

Primary LanguageTypeScriptGNU General Public License v3.0GPL-3.0

VSCode Stryker Mutator

GitHub GitHub Workflow Status (with branch) GitHub release (latest by date including pre-releases) GitHub Release Date

GitHub all releases GitHub stars Visual Studio Marketplace Downloads Visual Studio Marketplace Rating Open VSX Downloads Open VSX Rating

๐Ÿค” What is Stryker Mutator for VSCode

Stryker Mutator VSCode extension is a plugin for Visual Studio Code (& friends) that enables developers to use the Stryker Mutator mutation testing framework directly within their code editor. Mutation testing is a technique used to improve the quality of software by introducing faults (or "mutations") into the codebase and checking if the tests catch them. The Stryker Mutator framework automates this process by generating many variations of the code (with different mutations) and running the tests against each variation to see which mutations are caught and which ones slip through undetected.

This extension provides an easy-to-use interface for configuring and running the Stryker Mutator framework within your project. It allows you to customize the mutation testing process by specifying which selection, file, folder to launch the mutants against. It provides feedback on the progress and results of the mutation testing run. With the Stryker Mutator, you can easily improve the test coverage and overall quality of your codebase.

๐Ÿ“œ Note ๐Ÿ“œ

It's an unofficial extension for Stryker Mutator

It only supports .NET (C#) for Now.

If you are using JavaScript/TypeScript for your project, we suggest the use of pixabelle.stryker-runner

โ” Why use Stryker Mutator

Mutation testing is a powerful technique for improving the quality and reliability of your software. By automatically introducing faults into your codebase and checking if the tests catch them, you can identify weaknesses in your test suite and improve its effectiveness. However, setting up and running mutation testing manually can be time-consuming and error-prone. The Stryker Mutator streamlines the mutation testing process by providing an easy-to-use interface for configuring and running the Stryker Mutator framework within your code editor.

With Stryker Mutator, you can:

  • Improve the quality and reliability of your code by identifying weaknesses in your test suite and addressing them.
  • Catch bugs and issues that might otherwise go unnoticed.
  • Increase your confidence in your codebase by ensuring that your tests are effective at catching faults.
  • Save time and effort by automating the mutation testing process.
  • Customize the mutation testing process to fit your specific needs and requirements.
  • Easily integrate mutation testing into your development workflow by using the extension directly within your code editor.

Overall, Stryker Mutator is a powerful tool for any developer looking to improve the quality and reliability of their codebase.

โš ๏ธ Disclaimer โš ๏ธ

Mutation testing can be resource-intensive and may significantly slow down your build process. Stryker Mutator may consume a considerable amount of system resources and may require careful configuration to ensure optimal performance. We recommend that you test the extension on a selection on code, on a file or a small-scale project. Carefully review the Stryker Mutator's documentation to ensure that your configuration settings are appropriate for your project's needs. We are not responsible for any issues or damages that may arise from the use of this extension, and use of this extension is at your own risk.

๐Ÿงฑ Prerequisites

  • .NET SDK is require, [ at least we tested it with .NET 6 & 7 ]
  • VS Code ๐Ÿคฏ Obviously!!! & Friends (e.g.: VSCodium)

โš™๏ธ Usage

If you didn't have Stryker.Net installed and a configuration file, you should start with these steps while using the command Palette:

  1. Install the Stryker.NET tool. It may take time to install.
  2. Create [a basic] Stryker configuration file

Afterward, right-click on a file, on a folder or over a selection of your best (or worst ๐Ÿ˜ฌ) code and choose the Trigger mutation tests action that you want to perform.

๐Ÿš€ Features

Here is the list of all available (โœ”๏ธ) and upcoming (โŒ) features that will help you hunt mutants hiding in place sight:

  • Stryker.NET: Trigger mutation tests on file: Will run Stryker to mutate one specific file. Available in the:
    • Context Menu (โœ”๏ธ)
    • Command Palette (โœ”๏ธ)
  • Stryker.NET: Trigger mutation tests on selection: will run Stryker to mutate a selected block of code within the editor. Available in the:
    • Context Menu (โœ”๏ธ)
    • Command Palette (โœ”๏ธ)
  • Stryker.NET: Trigger mutation tests on solution: Will run Stryker to mutate files within the solution. Available, with a disclaimer (โœ”๏ธ), in the:
    • Context Menu (โœ”๏ธ)
    • Command Palette (โœ”๏ธ)
  • Stryker.NET: Trigger mutation tests on project: Will run Stryker to mutate files within the project. Available, with a disclaimer (โœ”๏ธ), in the:
    • Context Menu (โœ”๏ธ)
    • Command Palette (โœ”๏ธ)
  • Stryker.NET: Trigger mutation tests on folder: Will run Stryker to mutate files under one specific folder. Available, with a disclaimer (โœ”๏ธ), in the:
    • Command Palette (โœ”๏ธ)
  • [โ™ป๏ธ Deprecated, please use Stryker.NET: Trigger mutation tests on solution instead]
    Stryker.NET: Trigger mutation tests on workspace: Will run Stryker to mutate all files. Available, with a disclaimer (โœ”๏ธ), from the:
    • Command Palette (โœ”๏ธ)
  • Stryker.NET: Create Stryker.NET configuration file: Will create a default stryker configuration file in the chosen folder. Available from the:
    • Command Palette (โœ”๏ธ)
  • Stryker.NET: Install Stryker.NET Tool: Will install the latest version of stryker dotnet tool. It will use the settings to determine the Global or Local Installation. Available from the:
    • Command Palette (โœ”๏ธ)
  • Stryker.NET: Update Stryker.NET Tool: Will update the latest version of stryker dotnet tool. It will use the settings to determine the Global or Local Installation. Available from the:
    • Command Palette (โœ”๏ธ)
  • Stryker.NET: Uninstall Stryker.NET Tool: Will uninstall the stryker dotnet tool. It will use the settings to determine the Global or Local Installation. Available from the:
    • Command Palette (โœ”๏ธ)
  • Stryker.NET: Show the Report: Will display the latest generated mutation report. Available from the:
    • Command Palette (โŒ Alternatively, you could use --open-report:html in the optionalParameters setting)

๐Ÿ› ๏ธ Configuration

Even though the extension Stryker Mutator will work without any specific settings, there are some settings that you could take advantage of:

โœ”๏ธAvailable
โŒUpcoming
Settings Description
โœ”๏ธ strykerMutatorNet.dotnet.commandPath The command/path to invoke dotnet, if different than the default path/exe (default:dotnet)
โœ”๏ธ strykerMutatorNet.dotnet.solutionFolder Folder path to the dotnet solution file, if different than the workspace. The Path must be relative to the actual workspace
โœ”๏ธ strykerMutatorNet.stryker.configFile Path to a stryker config file, if different than the default name/workspace path
โœ”๏ธ strykerMutatorNet.stryker.optionalParameters Optional parameters to add with the command line. See the Configuration for more details (e.g. --verbosity info, --concurrency 2, --output ....)
โœ”๏ธ strykerMutatorNet.tool.installationLocation Installation location of the dotnet-stryker tool (default: global)
โŒ strykerMutatorNet.show-report Enable/Disable the browser opening the report. It requires the reporter html (default: false/disable). Alternatively, you could use --open-report:html in the optionalParameters setting

๐Ÿคฏ Known Issues

Unable to execute, because command or file cannot be found

Context

  • You are using a mono-repo style
  • And the workspace is not the root of the dotnet project
  • And you have manually installed stryker locally in the project instead of globally

Why does this happen?

Since we're using a "custom" terminal, named Stryker, to run the dotnet stryker command from the root workspace, it won't be able to access the dotnet tool manifest in a child folder.

How to make it work

Starting with version 0.6.0, you can specify the relative path to the .NET solution folder in settings.json, using the strykerMutatorNet.dotnet.solutionFolder config.

Itโ€™s advisable to use workspace settings to accommodate varying .NET solution folder locations across different projects.

๐Ÿ™‹ Support & Assistance

GitHub issues

  • โค๏ธ Please review the Code of Conduct for guidelines on ensuring everyone has the best experience interacting with the community.
  • ๐Ÿ™ Take a look at the support document on guidelines for tips on how to ask the right questions.
  • ๐Ÿž For all features/bugs/issues/questions/etc., head over here.

๐Ÿค Contributing

GitHub contributors GitHub pull requests GitHub last commit

  • โค๏ธ Please review the Code of Conduct for guidelines on ensuring everyone has the best experience interacting with the community.
  • ๐Ÿ“‹ Please review the Contributing document for submitting issues/a guide on submitting pull requests and helping out.

๐Ÿ‘ Acknowledgements

Thanks to:

๐Ÿ’– Donations / Sponsors

If you think this code/project is useful to you, I encourage you to make a donation to one of these foundations that I hold dear: Foundation for Prader-Willi Research Canada or International Prader-Willi Syndrome Organisation.

Prader-Willi syndrome (PWS) is a rare genetic disorder characterized at birth by severe hypotonia, growth disorders, learning disabilities and the appearance of hyperphagia (i.e. always being hungry) during childhood (usually appears between 2 and 8 years of age). Without adequate care (and sometimes despite care) this can lead to the development of morbid obesity. You can learn more about it on Wikipedia, on the Foundation for Prader-Willi Research website or on the International Prader-Willi Syndrome Organisation website.

โš–๏ธ License

This VSCode extension and source code is licensed under the terms of the GPL-3.0 license.

๐Ÿƒ Logo

The modified "logo" used in this project is licensed under CC-BY-4.0. The original image can be found on Flickr and was distributed under CC-BY-2.0.