MC/DC analizer for Python
Project description
pymcdc
A Python package to analyze and verify MC/DC (Modified Condition/Decision Coverage) criteria.
V 0.1.1 - add option --cover to manually set requeriment as covered/not covered
V 0.1.3 - allows source file and test file to be in different directories
V 0.2 - do some bug fixes.
Installation
pip install pymcdc
🚀 How to Use
Analyzes the file foo.py and displays the condition combinations that must be satisfied for each decision.
python -m pymcdc foo.py
Executes foo.py and shows which MC/DC combinations were covered.
python -m pymcdc --run foo.py
Executes foo.py with arguments ['bar', '1972'] and shows which MC/DC combinations were covered.
python -m pymcdc --run --args "bar 1972" foo.py
Cumulatively runs foo.py and displays the MC/DC combinations covered across multiple runs.
python -m pymcdc --run --append foo.py
Runs foo.py using the test cases defined in test_foo.py.
The --unittest argument can be used multiple times. The --append option is also supported here.
python -m pymcdc --unittest test_foo.py foo.py
python -m pymcdc --unittest tests/test_foo.py src/foo.py
Sets requirement 1 of decision (5,5) as covered and requirement 3 of decision (18,5) as not covered.
python -m pymcdc --cover +5 5 1 -18 5 3 foo.py
🔍 Example
python3 -m pymcdc bissexto.py
Line number: (5, 5)
Decision: a < 1 or a > 9999
Combinations to be covered:
| Result. a < 1 a > 9999 Cover.
-------------------------------------------
1 | False False False False
2 | True True False False
3 | True False True False
Run time: 0.00070
python3 -m pymcdc --run bissexto.py
Line number: (5, 5)
Decision: a < 1 or a > 9999
Combinations to be covered:
| Result. a < 1 a > 9999 Cover.
-------------------------------------------
1 | False False False True
2 | True True False False
3 | True False True True
python3 -m pymcdc --unittest test_bissexto.py bissexto.py
Running tests...
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
Line number: (5, 5)
Decision: a < 1 or a > 9999
Combinations to be covered:
| Result. a < 1 a > 9999 Cover.
-------------------------------------------
1 | False False False False
2 | True True False False
3 | True False True True
You can also use multiple --path <folder path> to include this folder in the sys.path variable for the interpreter. In this way, imports will also be searched in these folders.
📝 Notes
- The number of MC/DC requirements for a decision with
nconditions is not alwaysn+1. It can be slightly larger due to limitations in the computation algorithm. - For decisions with more than 15 conditions, the analysis may take a few minutes. This is only done once when using the
--appendoption.
👤 Author
Marcio Delamaro
📄 License
MIT
🤝 Contributions
Feel free to open issues or submit pull requests!
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymcdc-0.2.tar.gz.
File metadata
- Download URL: pymcdc-0.2.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
853dca277e1c39ea0ef17d13901ab90dff061d1ada87762c1926a6665cb9d07d
|
|
| MD5 |
d435b1f2c078eb89fe187c9a4a881165
|
|
| BLAKE2b-256 |
cbb1a9eb9b484cd94c782603918241501dedecd3d95d524ef45cb29882c5c6ea
|
File details
Details for the file pymcdc-0.2-py3-none-any.whl.
File metadata
- Download URL: pymcdc-0.2-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f40bae47682ffb87110b870328351e10e594a23d32b130a8882a39624b9d4607
|
|
| MD5 |
c45568a1581f899f0a09191458bc62ff
|
|
| BLAKE2b-256 |
b37373281dc68a6b2b0c29b5eb777f9f733efb17b6cfc33370ef03bddd4b3b04
|