Testing framework to check all RFEM Python Client objects and types. Using pytest
pkg enables user to run all test together or separately. This is to be maintained. Testing procedure should be exetuded before every commit to ensure compatibility.
- pytest or pytest (pdf documentation) Install by executing
pip install pytest
- coverage Install by executing
pip install coverage
- RFEM 6 application
- Open RFEM 6 application, NoAssert mode if possible. Always set language to English. The best version of RFEM is current GM, unless you are testing features that are not merged. Check if there are no opened dialogues in RFEM and server port range under Options-Web Services corresponds to the one set in initModel.
- Run whole
.\UnitTests
folder to exetue tests or.\UnitTests\Examples.py
to execute all examples. This ensure maximum scope. Execution is independent of current working directory. Pytest has many parameters it can be runned with. Refer to help (viapytest -h
) or documentation. Ensure that all tests are either passed or skipped conditionally.
> py -m pytest --tb=no .\RFEM_Python_Client\UnitTests # silent mode
> py -m pytest -s .\RFEM_Python_Client\UnitTests\test_zCalculate.py # verbose, printing out every print() in test
> py -m pytest .\RFEM_Python_Client\UnitTests\Examples.py # execute all examples
> py -m pytest .\RFEM_Python_Client\UnitTests\Examples.py --maxfail 1 # end after 1st fail
> py -m pytest --lf .\RFEM_Python_Client\UnitTests\Examples.py # run last failed tests
output: Indication: . - passed, s - skipped, e - error, f - failed
- This step is optional. To assess code coverage, run
coverage
. Pytest can be executed inside coverage process, leaving nothing out. Coverage enables to automaticaly create formated output (html, json, or dxf). Again, for more information refer to help (coverage -h
) and html (coverage html -h
). In html the results can be sorted out or filtered. Files can be inspected separately. Coverage results can be directed into UnitTests folder since they are ignored by github and they will not be commited to repository. Use separate folder for the results. There is a lot of files generated.
> py -m coverage run -m pytest --tb=no .\RFEM_Python_Client\UnitTests
...
> py -m coverage html [target folder]
> start [target folder\index.html]
Contributions are always welcome! Just be sure to start with UnitTests/template.py