mirror of https://github.com/zulip/zulip.git
test-backend: Display test function in HTML coverage reports.
This commit is contained in:
parent
814841c9ec
commit
492272d597
|
@ -481,6 +481,10 @@ Here are some things to consider when writing new tests:
|
||||||
view right from your browser (the tool prints the URL where the report
|
view right from your browser (the tool prints the URL where the report
|
||||||
is exposed in your development environment).
|
is exposed in your development environment).
|
||||||
|
|
||||||
|
The HTML report also displays which tests executed each line, which
|
||||||
|
can be handy for finding existing tests for a code path you're
|
||||||
|
working on.
|
||||||
|
|
||||||
- **Console output** A properly written test should print nothing to
|
- **Console output** A properly written test should print nothing to
|
||||||
the console; use `with self.assertLogs` to capture and verify any
|
the console; use `with self.assertLogs` to capture and verify any
|
||||||
logging output. Note that we reconfigure various loggers in
|
logging output. Note that we reconfigure various loggers in
|
||||||
|
|
|
@ -24,6 +24,13 @@ exclude_lines =
|
||||||
|
|
||||||
[run]
|
[run]
|
||||||
data_file=var/.coverage
|
data_file=var/.coverage
|
||||||
|
|
||||||
|
# dynamic_context=test_function, combined with using
|
||||||
|
# html_report(..., show_contexts=True), means the HTML report can detail
|
||||||
|
# which test(s) executed each line with coverage. This has modest
|
||||||
|
# overhead but is very useful for finding existing tests for a code path.
|
||||||
|
dynamic_context=test_function
|
||||||
|
|
||||||
omit =
|
omit =
|
||||||
*/zulip-venv-cache/*
|
*/zulip-venv-cache/*
|
||||||
*/migrations/*
|
*/migrations/*
|
||||||
|
|
|
@ -442,7 +442,7 @@ def main() -> None:
|
||||||
print("Printing coverage data")
|
print("Printing coverage data")
|
||||||
cov.report(show_missing=False)
|
cov.report(show_missing=False)
|
||||||
cov.xml_report(outfile="var/coverage.xml")
|
cov.xml_report(outfile="var/coverage.xml")
|
||||||
cov.html_report(directory="var/coverage")
|
cov.html_report(directory="var/coverage", show_contexts=True)
|
||||||
print("HTML report saved; visit at http://127.0.0.1:9991/coverage/index.html")
|
print("HTML report saved; visit at http://127.0.0.1:9991/coverage/index.html")
|
||||||
if full_suite and not failures and options.coverage:
|
if full_suite and not failures and options.coverage:
|
||||||
# Assert that various files have full coverage
|
# Assert that various files have full coverage
|
||||||
|
|
Loading…
Reference in New Issue