Add tox environment to generate HTML test case reports.
By typing below commands it generates HTML report file of Python test case results: tox -e report It generates 'report/build/testr_results.html' file. To run test cases (for example scenario tests) and produce report HTML file it is possible to chain tox environment names in a list. For example: tox -e scenario,report Or simply: tox -e scenario tox -e report This new environment is intended to be used in CI jobs to produce reports after verifications. Change-Id: I63d4d2977fb5b2c868361aa00db0e1334f33fa10
This commit is contained in:
parent
0ba711e498
commit
f3b835a57b
1
report/.gitignore
vendored
Normal file
1
report/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build/
|
19
report/build.sh
Executable file
19
report/build.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Produce test HTML report file into ${REPORT_DIR}
|
||||
|
||||
set -xeu
|
||||
|
||||
|
||||
TESTR_DIR=${TESTR_DIR:-$(pwd)}
|
||||
BUILD_DIR=${BUILD_DIR:-${TESTR_DIR}/report/build}
|
||||
SUBUNIT_FILE=${SUBUNIT_FILE:-${BUILD_DIR}/last.subunit}
|
||||
TESTR_RESULTS_HTML=${TESTR_RESULTS_HTML:-${BUILD_DIR}/testr_results.html}
|
||||
|
||||
make_testr_results_html() {
|
||||
mkdir -p "$(dirname ${SUBUNIT_FILE})"
|
||||
(cd "${TESTR_DIR}" && stestr last --subunit) > "${SUBUNIT_FILE}"
|
||||
(cd "${BUILD_DIR}" && subunit2html "${SUBUNIT_FILE}" "${TESTR_RESULTS_HTML}")
|
||||
}
|
||||
|
||||
make_testr_results_html
|
4
report/requirements.txt
Normal file
4
report/requirements.txt
Normal file
@ -0,0 +1,4 @@
|
||||
# Requirements file for 'report' Tox environment
|
||||
|
||||
os-testr>=1.0 # Apache 2.0
|
||||
stestr>=2.0 # Apache-2.0
|
8
tox.ini
8
tox.ini
@ -143,7 +143,7 @@ whitelist_externals = *
|
||||
commands = {posargs}
|
||||
|
||||
|
||||
# --- documentation environments ---------------------------------------------
|
||||
# --- documentation environments ----------------------------------------------
|
||||
|
||||
[testenv:docs]
|
||||
|
||||
@ -169,3 +169,9 @@ deps = {[testenv:docs]deps}
|
||||
commands =
|
||||
sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
|
||||
|
||||
|
||||
# --- CI report environments --------------------------------------------------
|
||||
|
||||
[testenv:report]
|
||||
deps = -r {toxinidir}/report/requirements.txt
|
||||
commands = {toxinidir}/report/build.sh
|
||||
|
Loading…
Reference in New Issue
Block a user