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.
V 0.2.1 - 'Don't care' conditions are shown in the requirements lists.
V 0.2.2 - Introduces argument --assert to enable analysis on assert statements.
Installation
pip install pymcdc
🚀 How to Use
Analyzes the file foo.py and displays the condition combinations that must be satisfied for each decision.By default assert statements are not considered to generate MC/DC requirements. This can be changed with --assert argument.
python -m pymcdc foo.py
python -m pymcdc --assert 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 isleap.py
Line number: (5, 5)
Decicion: a < 1 or a > 9999
Combinations to be covered:
| Result. a < 1 a > 9999 Cover.
-------------------------------------------
1 | False False False False
2 | True True ---- False
3 | True False True False
Covered 0 out of 3 requirements in 1 decisions (0%)
Run time: 0.00052
python3 -m pymcdc --run isleap.py
Line number: (5, 5)
Decicion: a < 1 or a > 9999
Combinations to be covered:
| Result. a < 1 a > 9999 Cover.
-------------------------------------------
1 | False False False True
2 | True True ---- False
3 | True False True True
Covered 2 out of 3 requirements in 1 decisions (66%)
python3 -m pymcdc --unittest test_isleap.py isleap.py
.
----------------------------------------------------------------------
Ran 1 test in 0.000s
OK
Line number: (5, 5)
Decicion: a < 1 or a > 9999
Combinations to be covered:
| Result. a < 1 a > 9999 Cover.
-------------------------------------------
1 | False False False False
2 | True True ---- False
3 | True False True True
Covered 1 out of 3 requirements in 1 decisions (33%)
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.
The symbol '----' is used to indicate that the value for that part of the requirement does not matter in the verification. This is due to the language's decision evaluation strategy (short-circuiting).
📝 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.2.tar.gz.
File metadata
- Download URL: pymcdc-0.2.2.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70cf0b50f8f57c605e4365df6ad140bb1cd5e5d22838f6a971d84dd2dcb5e757
|
|
| MD5 |
e50af2a34b50552e4ba6f3007ca30aed
|
|
| BLAKE2b-256 |
1f1b188f24cba846b6a48816c485b013c4b125ee1a088f7884447062fe4ec426
|
File details
Details for the file pymcdc-0.2.2-py3-none-any.whl.
File metadata
- Download URL: pymcdc-0.2.2-py3-none-any.whl
- Upload date:
- Size: 13.3 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 |
18cd5d1828d5d4b5559eab61a86abc094bef62b2998aeee337208e6bd1d78b6e
|
|
| MD5 |
182cf5129481929802560817c44cf8bd
|
|
| BLAKE2b-256 |
1d245f30660663e65fe91435676c58a253f08c96f86f2a1b1e90bb0e70f3bcba
|