Coverage-driven automatic unit test generator for Python projects.
Project description
Pyster
Pyster is a coverage-driven automatic unit test generator for Python projects.
Pre-request
- Python 3
- Coverage.py (
pip3 install coverage
) - pytest (
pip3 install pytest
)
Usage
# Stage 1: Init pyster config file
python3 -m pyster.init \
--project_path <path-to-project> \
--module_name <module-for-testing> \
--path_runtime <runtime-analysis-code>
# Stage 2: Generate unit tests
python3 -m pyster.gen \
--project_path <path-to-project> \
--module_name <module-for-testing> \
--user_tests <list-of-existing-test-files> \
--timeout <timeout-limit> \
--coverage <coverage-target>
# Run Stage 1 and Stage 2 together:
python3 -m pyster \
--project_path <path-to-project> \
--module_name <module-for-testing> \
--path_runtime <runtime-analysis-code> \
--user_tests <list-of-existing-test-files> \
--timeout <timeout-limit> \
--coverage <coverage-target>
Test
pytest tests
Sample execution
# Phase 1
python3 -m pyster.init --project_path tests/foobar --module_name foobar.foobar
# Phase 2
python3 -m pyster.gen --project_path tests/foobar --module_name foobar.foobar -t 1 -c 80
Concept
- Use built-in Python functions to obtain all methods in a Python class.
- According to the methods input, randomly generate an object instance and function arguments, with special inputs (
0
,-1
for integers,[]
for lists andNone
for objects also into consideration). Usecoverage.py
third-party library to get the coverage rate increment after calling the randomly generated function call. - Repeat step 2 until we reached 100% coverage rate or the target coverage rate from user input, or the specified timeout is reached.
- Dump all auto-generated unit tests into a test file and save it into the project test suite directory, together with a before/after coverage rate of the class.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyster-python-0.0.1.tar.gz
(11.0 kB
view hashes)
Built Distribution
Close
Hashes for pyster_python-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28f62a714c84f8245162ef2d37d8cfd20dd10bab2cf9c9570941d202bef9e04f |
|
MD5 | 7283645a45fbde8d8827f18c522cbd71 |
|
BLAKE2b-256 | 2c29e7a6eac30e75ece1e00ec16757dad65379b37c265236e07a03da9b0f9de2 |