|
|
2 years ago | |
|---|---|---|
| taskManager | 2 years ago | |
| tests | 2 years ago | |
| .gitignore | 2 years ago | |
| .mutmut-cache | 2 years ago | |
| README.md | 2 years ago | |
| XXtasks.jsonXX | 2 years ago | |
| openapi.json | 2 years ago | |
| poetry.lock | 2 years ago | |
| pyproject.toml | 2 years ago | |
| tasks.json | 2 years ago | |
README.md
Mutation Testing - Practical Assignment 1 (4pts)
Task Manager - Project
In this repository, you are given a simple task manager project that features basic CRUD operations on tasks. You are required to write unit tests for this project and apply mutation testing to improve your tests.
Note: We use poerty for dependency management, pytest for running tests and mutmut for mutation.
-
Setup:
- Ensure
pytestandmutmutare installed:poetry add pytestpoetry add mutmut
- Ensure
-
Implementation:
- Write tests for both modules of the project [Task, TaskManager] inside
/tests/test_taskManager.py
- Write tests for both modules of the project [Task, TaskManager] inside
Note: Build you tests inside of
./tests/test_taskManager.pysee the test file and strictly follow the provided example.
-
Execution:
- Run tests using:
poetry run pytest ./tests/test_taskManager.py
- Run tests using:
-
Mutation testing:
- Run mutmut using:
poetry run mutmut run --paths-to-mutate ./taskManager/ --runner="pytest tests/test_taskManager.py
- Run mutmut using:
-
Check results:
- Use:
poetry run mutmut showpoetry run mutmut results
- Use:
-
Analyze survived mutations and improve tests:
- Run:
poetry run mutmut show <id>
- Run:
Note: Requirements to pass: Minimum number of mutations to cover with tests: 20 For example: You will have a lot of mutations that are not meaningful. You have to get rid of them using
# pragma: no mutate. Then when you have the set of meaningful mutations - you have to kill them using your tests.
Random Testing - Practical Assignment 2 (2pts)
InnoDrive - Problem
The InnoDrive is a hypothetical autonomous car-sharing service that provides transportation in the Kazan region and was created by SQR graduates from Innopolis. The service proposes two types of cars budget and luxury. The service offers flexible two tariff plans. With the “Minute” plan, the service charges its client by time per minute of use. The Service also proposes a “Fixed price” plan where the price is fixed at the reservation time when the route is chosen. If the driver deviates from the planned route for more than 10%, the tariff plan automatically switches to the “Minute” plan. The deviation is calculated as the difference in the distance or duration from the initially planned route. The “Fixed price” plan is available for budget cars only. The Innopolis city sponsors the mobility and offers a 10% discount to Innopolis residents.
You are a member of the quality assurance team at InnoDrive. You learned about input domain testing methods and would like to apply them to the billing application that charges the client when he or she completes the ride.
Note: the exact tariffs, deviation % and discount % will differ for your individual case see below.
InnoDrive Service
The InnoDrive app offers 2 services that can be accessed via the following URL https://instructors.pg.innopolis.university/innodrive/:
-
/spec- provides you with the specification for your individual problem- you_email is your IU e-mail address in all lowercase letters e.g. i.ivanov@innopolis.university
-
/rangeprice- calculate the price for a given ride. The possible input parameters are:- type={budget|luxury}
- plan={fixed_price|minute}
- distance=110
- planned_distance=100
- time=110
- planned_time=100
- inno_discount={yes|no}
-
the output is the price calculated according to the specification
- In case of error, 406 Not Acceptable: is raised with the Error code: Price == -1
- In case of the type error, 422 Unprocessable Entity is raised
Note: You can see the API and try the services at https://instructors.pg.innopolis.university/innodrive/docs
Tasks
The customers have discovered some anomalies in the InnoDrive services when applying minute plans for both types of cars. The input space is enormous, and exhaustive testing of all inputs is out of the question.
With the help of the Hypothesis, identify at least one failing test case for time parameter in the range of 1-1000 minutes. Prevent exhaustive search and minimize executions.
Note: Build you tests inside of
./tests/test_innodrive.pysee the test file and strictly follow the provided example.
Email: i.ivanov@innopolis.university
Note: Make sure to replace the email with your Innopolis email
Error in the Time range
Please replace each __ with a time parameter value in minutes for which a failure occurred. Example (100):
Note: Keep round brackets
-
Budget plan failure on Time = (124)
-
Luxury plan failure on Time = (817)
Useful resources
http://testdriven.io/blog/testing-python/
https://mutmut.readthedocs.io/en/latest/