This project demonstrates the use of mutation testing in Python using mutmut
. Mutation testing helps in evaluating the quality of your test cases by introducing changes (mutations) to your code and checking if your tests can detect these changes.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Python 3.10.13
- pipenv
If you don't have pipenv
installed, you can install it via pip:
pip install pipenv
First, clone the repository to your local machine:
git clone https://github.com/hernanzini/mutmut_demo.git
cd path/to/cloned/repository
Then, use pipenv to create a virtual environment and install the required dependencies:
pipenv install --dev
This will create a virtual environment and install the packages defined in Pipfile.
To interact with the project within the virtual environment, you have two options:
pipenv shell
If you prefer not to activate the virtual environment, you can still run commands within it by prefixing them with pipenv run <command>
.
To run the standard test suite using pytest:
pytest -v
pytest --cov=src
pytest --cov=src --cov-report term-missing
pytest --cov=src --cov-report html
To perform mutation testing with mutmut:
mutmut run
After running mutation testing, you can check the results with:
mutmut results
To apply a mutant on disk:
mutmut apply <id>
To show a mutant:
mutmut show <id>
To view a more detailed HTML report of the mutation testing results:
mutmut html
Then, open the generated HTML file in your browser to view the report.
open html/index.html
For convenience, a script named mutmut.sh
is included to automate the mutation testing process, generate the HTML report, and open it:
./mutmut.sh
We welcome contributions to the Mutation Testing Demo! If you have an improvement or a bug fix, please follow these steps:
- Fork the repository.
- Create a new branch with a descriptive name for your feature or bug fix.
- Implement your changes. Make sure your code follows the project's style and has been tested.
- Submit a pull request with a clear description of what your changes are.
This project is made available under the terms of the MIT License. By contributing to or using the Mutation Testing Demo, you agree to abide by its terms.