mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
* doc(tests/README.md): explain the unit test process
* test(TempRepository): support to change origin and get filename
* refactor: simplify the case code
* test_git_browse_ci.py
* test_git_browse.py
* fix: rename `test_authors.py` to `test_git_authors.py`
* fix: typo
* fix: log the GitCommandError
1.6 KiB
1.6 KiB
Test for git-extras
The git-extras has its own testcases now, and the more is on the way! So let's introduce it.
We choose python to help us to reach to other shore cause python is life saver.
The test part depends on:
- python >= 3.11
- poetry >= 1.7.1
- pytest >= 7.4
- gitpython >= 3.1.40
So the versions are higher than above is recommended.
How to run the tests
- Install
poetry - Install the dependencies via
poetry install --no-root - Run
poetry run pytest
It is done or go without poetry,
- Install python >= 3.11
- Install pytest >= 7.4
- Install gitpython >= 3.1.40
- Run
pytest
The second way maybe blocked the some missing dependencies at someday, so the first one is recommended.
What and how to create a unit test
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