Skip to main content

Welcome to the RoboBar 🤖🍷

An introduction to mutation testing

How code coverage of 100% could mean only 60% is tested.

RoboBar application


No time to run the example yourself? Don't worry. We did it for you. Open it right in your browser:

What is this?

The RoboBar is a small application to demonstrate mutation testing. It actually has a fair number of unit tests. When we wrote this application, we didn't even try our best to write bad tests. We just focussed on code coverage and didn't practice Test Driven Development. It turns out it's straightforward to write bad tests or forget a few essential test cases. The RoboBar even has a reasonably large bug. Finding it is pretty easy using the mutation report. Why don't you give it a try? 😁

Try it yourself

  1. Install git
  2. Install nodejs
  3. Open command prompt and clone this repository:
    git clone
  4. Change directory into the robobar and install the dependencies.
    cd robobar-example
    npm install
  5. Run tests with npm. This will generate a code coverage report.
    npm test
  6. Review the 100% code coverage score. Open up the code coverage report located in the reports/coverage/lcov-report/index.html file.
  7. Run mutation testing with Stryker
    npm run test:mutation
  8. Review the 50% mutation score. Open up the mutation report located in the reports/mutation directory.
  9. Run the website with npm start. Can you find the bug?

Try to install stryker yourself.

If you want to install stryker yourself, step back in history using git:

git reset --hard
git checkout e92b8d4
npm install

After that you can install stryker for yourself:

npm i -g stryker-cli
stryker init

Choose the following options in the questionnaire:

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

After the plugins are installed, try it out:

stryker run