This post is about the Stryker Runner Visual Studio Code extension that is intended to allow users to easily and selectively run the Stryker mutation testing library against Javascript and Typescript projects.

What is Stryker?

The Stryker project is a collection of libraries for languages including C# , Scala and Javscript that are used to run mutation tests against your codebase. In the context of this post Stryker will always be referring to the Javascript/Typescript library, the extension does not currently support any other languages.

What is mutation testing?

Mutation testing is the programmatic changing or rewriting of parts of your code (a mutant) and validating whether the existing unit tests fail. The idea is that they do fail (killing the mutant), that is the theory anyway if you want to kill 100% of mutants.

Unit testing frameworks (like Jest for Javascript) can tell you how much of your code is covered by unit tests but this really just means which code gets executed under the tests. Unit testing frameworks cannot tell you how much of the desired behaviour is adequately tested and this information is a part of what mutation testing attempts to solve. The Stryker docs have a brief intro on this as well.

What is VS Code?

Visual Studio Code (VS Code) is free and widely used IDE developed by Microsoft. VS Code has access to an official marketplace of extensions that are used to add additional functionality, integrate libraries like Stryker and even add additional language support. There are also unofficial marketplaces that can be used instead of, or as well as, the official one, e.g. the open source marketplace Open VSX.

Stryker Runner: the extension

Why bother writing an extension for VS Code now when the Stryker library for Javascript project has been around for 5 years at this point? Mostly because of the experience I have been having working with projects that heavily use Stryker mutation testing, I found that the developer experience was a little painful.

I think there is a lot of value in mutation testing your projects and I think Stryker is a great option. But because of the nature of what mutation testing is, what Stryker is trying to achieve and how it works Stryker can be a little painful to use sometimes. Depending on the size and complexity of the codebase, as well as the computing resources available, Stryker tests can be incredibly time consuming to run and lengthen the development feedback loop.

With Stryker you can run mutation testing against single files as well as against specific line ranges in files using the CLI. These approaches can really shorten that potential feedback loop during local development. The original idea of this extension was to surface this functionality into VS Code for developers.

How do I use it?

  • Against single files:
    1. Right click on a file in the file tree in VS Code
    2. This will present the context menu, the extension adds an item to the menu: Run Strkyer on file
    3. Choosing this option will run Stryker against just that file in a new terminal
  • Against a line range in a file:
    1. Select some code in a file in VS Code
    2. Right click within the file
    3. This will present the context menu, the extension adds an item to the menu: Run Strkyer
    4. Choosing this option will run Stryker against the selected line range in just that file in a new terminal

Summary

A small group of developers have so far found the Stryker Runner extension to be useful, saving a lot of time in resolving the outputs from the mutation tests. If Stryker Runner sounds like something that might be useful in your workflow it would be great if you could give it a try. If there any issues, bugs, feature requests of any other kind of feeback please do get in contact or create an issue in the repo.

The source for the Stryker Runner extension is available on Github.

The .vsix extension package can be downloaded directly from Github or is available in the VS Code marketplace.

Get in contact

If you have comments, questions or better ways to do anything that I have discussed in this post then please get in contact.