Getting Started with Automated Mutation Testing using Stryker CLI

Getting Started with Automated Mutation Testing using Stryker CLI
Milesh Jivan
Software Quality Engineer
What is Mutation Testing?

Mutation testing is the practice of automatically inserting mutants into your application’s source code. The main function of a mutant is to morph the functions of your unit test. If your test fails, the mutant is killed. If your tests pass, the mutant survives. The more mutants you kill, the more effective are your tests.

What is the benefit of Mutation Testing?

Code coverage does not tell us everything we need to know that can define how effective your unit tests are. The use of assertions is predominantly the most common way to increase code coverage. Code coverage defines the bigger picture for us, while mutation testing allows us to ensure that inside those pieces that make up the picture, the code does in-fact work as intended.

Introducing Stryker:

Stryker is an easy to use and highly customisable Node Packet Manager (NPM) module that can be used to implement mutation testing on three platforms. We will be looking at setting up these platforms and running an example website, this will demonstrate how Stryker mutates your source code, ensuring that there are no false positives.

NPM and Git:

We will be utilizing NPM to install all the modules required for Stryker.
If node is not installed, please ensure that you have installed node Js and the NPM modules first. Once installed, we will also install two additional Node Packages: Karma (Test Runner) and Jasmine (Test Framework). We will use GIT to clone a test project to run it against Stryker.

Lets try it:

Open terminal/command prompt and run the following command

git clone

Change directory into the robobar and install the dependencies

cd robobar-example
npm install

Next install stryker

npm i -g stryker-cli
stryker init

Select the following Options

  • Install stryker?: Yes
  • Test runner: Karma
  • Test framework: Jasmine
  • Language: javascript
  • Transformations: none
  • Reporters: html, clear text, progress

After these are installed simply run Stryker(Ensure you are in the root of your project)

stryker run

You can view your reports in the following location inside of your file directory:


Tagged under