Improve unittest
- [x] use PyTest as a default test framework (have a look on official site, migration can be done softly with https://docs.pytest.org/en/8.2.x/how-to/unittest.html)
- [x] Split memory leak test in a specific file
- [x] Create a performance test
- [x] Improve tests by testing all the plugin/model.py methods
- [ ] Add dummies tests for all plugins (for example sensors could not be tested in the CI because the CI containers do not expose any sensors)
- [ ] https://github.com/nicolargo/glances/issues/2749
- [ ] write tests using Gherkin (Cucumber / Behave): see example here: https://github.com/ritvik-shetty/BDD_DEMO/tree/main/bdd_test
- [x] https://github.com/nicolargo/glances/issues/3044
Improve tests by testing all the plugin/model.py methods done in Glances 4.0.0
Pytest tesbed
Include existing unittest
./venv/bin/pip install pytest
ln -s unittest-core.py test_core.py
./venv/bin/pytest
..................................... [100%]
37 passed in 20.43s
Also work with other unitest file:
ln -s unittest-restful.py test_restful.py
ln -s unittest-xmlrpc.py test_xmlrpc.py
./venv/bin/pytest
...................................................................... [100%]
70 passed in 31.61s
Add new Pytest tests
Example:
cat /home/nhe/dev/glances/glances/timer_test.py
from .timer import Timer
def test_timer():
t = Timer(5)
assert t is not None
./venv/bin/pytest
. [100%]
1 passed in 0.09s
This issue is stale because it has been open for 3 months with no activity.
For PyTest migration (have a look to https://github.com/giampaolo/psutil/commit/42c7a241c1caf8d723dc360422db937d6036b40f)
Some interesting read: https://www.agest.am/write-good-python-tests
For integration test: https://www.docker.com/blog/running-testcontainers-tests-using-github-actions/