Hey @felixfontein - Whilst reviewing the pytest-ansible source I did notice an option for running molecule scenarios called skip_no_git_change: pytest-ansible/src/pytest_ansible/molecule.py at main · ansible/pytest-ansible · GitHub
I can’t find any documentation on this option (sigh…) but it looks to skip scenarios when no changes are detected via git diff to the role. However, it appears to be outdated given the newest convention for molecule scenario location inside a collection is extensions/molecule. It’s looking for molecule scenarios inside the role directory itself (e.g., roles/<role>/molecule/<scenario>/molecule.yml).
Regarding code coverage, I wanted to see if I could get pytest-cov working with tox-ansible and I have managed to with the use of .coveragerc and slight modification to the tox-ansible.ini file: Implement tox-ansible for collection testing by dbrennand · Pull Request #40 · ansible-collections/community.beszel · GitHub
It would be nice if this could be a supported feature out of the box, say like a --coverage argument:
unit-py3.10-2.17: commands[0]> python3 -m pytest --cov --cov-config=.coveragerc --ansible-unit-inject-only ./tests/unit
======================================================================== test session starts =========================================================================
platform darwin -- Python 3.10.20, pytest-9.0.3, pluggy-1.6.0
cachedir: .tox/unit-py3.10-2.17/.pytest_cache
ansible: 2.17.14
rootdir: /Users/dab/github.com/dbrennand/community.beszel
configfile: pyproject.toml
plugins: ansible-26.4.0, cov-7.1.0, xdist-3.8.0, anyio-4.13.0
collected 26 items
tests/unit/plugins/modules/test_system.py .......... [ 38%]
tests/unit/plugins/modules/test_system_info.py .... [ 53%]
tests/unit/plugins/modules/test_universal_token.py ............ [100%]
=========================================================================== tests coverage ===========================================================================
_________________________________________________________ coverage: platform darwin, python 3.10.20-final-0 __________________________________________________________
Name Stmts Miss Cover Missing
------------------------------------------------------------------------
plugins/module_utils/pocketbase_utils.py 33 25 24% 9-12, 17-23, 27-36, 40-49
plugins/modules/system.py 101 22 78% 176-178, 208-209, 232, 263-264, 273-274, 289-299, 313-314, 369-370, 393-394, 406
plugins/modules/system_info.py 38 7 82% 127-129, 153, 174-175, 191
plugins/modules/universal_token.py 52 5 90% 109-111, 145, 202
------------------------------------------------------------------------
TOTAL 224 59 74%
========================================================================= 26 passed in 0.30s =========================================================================
unit-py3.10-2.17: OK (10.56=setup[1.46]+cmd[7.61,0.41,1.09] seconds)
congratulations :) (11.05 seconds)