From e46c81c99303b7d955056e560d40876d869aea73 Mon Sep 17 00:00:00 2001 From: YuehuCao Date: Mon, 28 Jul 2025 11:09:46 +0800 Subject: [PATCH] docs(tests): add guide for generating coverage reports --- apps/notification/tests/README.md | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 apps/notification/tests/README.md diff --git a/apps/notification/tests/README.md b/apps/notification/tests/README.md new file mode 100644 index 0000000..c534c63 --- /dev/null +++ b/apps/notification/tests/README.md @@ -0,0 +1,32 @@ +## unittest +```shell +# run the command + +cd test/unit_test +python -m pytest unit_test_file.py -v --cov=backend.tested_directory --cov-report=html +``` +After the test is completed, a htmlcov folder will be generated. The test result is in the htmlcov/index.html. + +## integration test +```shell +# run the command + +cd test/integration_test +python -m pytest integration_test_file.py -v -s --html=report.html --self-contained-html --asyncio-mode=auto + +``` +After the test is completed, a report.html will be generated. The test result is in the file. +```shell +python integration_test_file.py +python -m coverage html --include="../../backend/tested_directory/*" +``` +After the test is completed, a htmlcov folder will be generated. The test result is in the htmlcov/index.html. + + +## Q & A +### Q: ModuleNotFoundError: No module named 'backend' +```shell +# export freeleaps code path + +export PYTHONPATH="/yourpath/freeleaps-service-hub/apps/notification" +``` \ No newline at end of file