Originally, the tests were written in pytest. However, tests are in the process of being converted to Bats so coverage can be calculated.
We require a somewhat recent version of Bats. Version v1.8.1 is tested in CI. Once it is installed, the tests can be executed like so:
bats ./testsWe highly recommend adding tests for new features and fixes.
Coverage can be calculated with bashcov like so:
bashcov -- bats ./testsBy default, the report will be generated in ./coverage/index.html.
The test part depends on:
- python >= 3.11
- poetry >= 1.8.0
- pytest >= 8.1.2
- gitpython >= 3.1.43
So the versions are higher than above is recommended.
- Install
poetry - Install the dependencies via
poetry install - Run
poetry run pytest
It is done or go without poetry,
- Install python >= 3.11
- Install pytest >= 8.1.2
- Install gitpython >= 3.1.43
- Install testpath >= 0.6.0
- Run
pytest
The second way maybe blocked the some missing dependencies at someday, so the first one is recommended.
One command has a unit test, because one git-* command is just do one thing, so we can eat a piece of git-* command in one time.
For example,
- The
git-aliasshould have a test suite, so createtest_git_alias.pyin the directorytest - Create a test class
TestGitAliasin thetest_git_alias.py - Create a test case
test_init, and some test fixtures can be used,temp_repo,named_temp_repoetc.temp_repois module scoped fixture which create a temporary directory and available in the test suitetest_git_alias.py.named_temp_repois just same astemp_repoexcept the custom directory renaming.
- Loop the third step until the 100% coverage of the function of the
git-alias