This is the contribution guide for Stryker4s. Great to have you here! Here are a few ways you can help to make this project better.
To get started with developing Stryker4s, you'll need a couple of tools:
If you use VS Code with Metals, you can also install the Bloop CLI for easier compiling and testing via the command-line.
If you are have issues with setup, or want to keep a clean environment you can also use the VS Code Remote Containers feature to develop in a clean reproducible Docker container. All you need for it is VS Code, the Remote Containers extension and Docker. Then run 'Remote-Containers: Open Repository in Container...' and enter
stryker-mutator/stryker4s as the repository. The devcontainer also has the Bloop and Coursier CLI tools installed.
Adding a new feature
New features are welcome! Both as ideas or in the form of a pull request.
- Please create an issue with your idea first or let us know via Gitter.
- Create a fork on your GitHub account.
- When writing your code, please conform the existing coding style. We use Scalafmt as a code formatter. You can format your code by running
./bin/scalafmt, or with editor-specific settings. It also helps to take a moment to review the Scala style guide.
- Please create or edit unit/integration tests for any changed or added code.
- Confirm everything still works by running
sbt test(or let the CI do the work for you).
- Submit the pull request!
Don't hesitate or get discouraged to get in touch! We are always happy to help you if you get stuck or have a question. Even if you don't finish something it can still be a good contribution.
Running Stryker4s on Stryker4s
We support mutation testing Stryker4s with Stryker4s! The easiest way is to follow our guide in the root readme. If you want to test any local changes, follow these steps:
sbt sbt-stryker4s2_12/publishLocalto publish the snapshot version to your local ivy repository.
- Note the version outputted by the log. Sbt will output something like
[info] published sbt-stryker4s to $HOME/.ivy2/local/io.stryker-mutator/sbt-stryker4s/scala_2.12/sbt_1.0/0.6.1+31-85939087-SNAPSHOT/jars/sbt-stryker4s2_12.jar. In this case
0.6.1+31-85939087-SNAPSHOTis the version you need (based on the commit hash and some other information, gathered by
- Alternatively, set the
versionin sbt to something easier before calling
- Alternatively, set the
- Add the sbt plugin to
project/plugins.sbtwith the new version number
- Run stryker4s as described in the readme.
Here are some resources you can use if you are new to mutation testing:
- What is mutation testing? (and the rest of the website). On the Stryker mutator website.
- Mutation Testing: Complete Guide - Guru99
- Scala Days 2019 - Daniel Westheide - Testing in the postapocalyptic future
Stryker4s uses a technique called 'mutation switching' to perform mutations. It does this by adding all mutations into a single pattern match, and activating the correct mutation via an environment variable. This would change the following code:
The effect is the same as compiling each mutation seperately, but instead we only have to do it once. This is a big performance improvement, but does mean we have to be more careful about compile errors. Read more about mutation switching on our blog
Want to help in some other ways? Great! Here are some things you could do:
- Evangelize mutation testing
- Mutation testing is still relatively new, especially in Scala. Please help us get the word out there!
- Share your stories in blog posts and on social media. And please let us know about it!
- Did you use Stryker4s? Your feedback is very valuable to us. Both good and bad! Please contact us to let us know what you think.