Skip to content

Instantly share code, notes, and snippets.

@PurpleBooth
Last active March 20, 2021 12:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PurpleBooth/cd5e56ca0e23a6250ab509a97420a0f6 to your computer and use it in GitHub Desktop.
Save PurpleBooth/cd5e56ca0e23a6250ab509a97420a0f6 to your computer and use it in GitHub Desktop.

Mutation Testing

How good are the tests you've been writing all day, and yesterday?

The Command

We're going to use mut.py to run our mutation tests. There are a LOT of options for mutation testing in python, if you find a better one, tell me about it.

Installing mut.py into the environment

pipenv install --dev mutpy

Running mut.py

pipenv run mut.py -c -m -e --runner pytest -t bowling_game -u test_bowling_game
  • -c makes the output pretty
  • -e includes experimental mutations
  • -m prints the mutations to screen
  • --runner pytest tells it to use pytest to run the mutations
  • -t bowling_game tells it to mutate the bowling game module
  • -u tells it to run the test_bowling_game module to check that it works

The Task

Run this for the bowling game kata completed branch

  1. What do you see?
  2. Fix the tests

Run this for any code you have written today or yesterday

  1. What do you see?
  2. Fix the tests

Run this for the team you are going to be working with's codebase

  1. What do you see?
  2. Fix the tests

Note: Given this might turn out to be hard (I don't know how good the codebase you're working on is going to be), ask for help or group up with someone else who has managed it if you get totally stuck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment