From 1738b9acf35017603fdc53e4e3b65578c0a4b8e9 Mon Sep 17 00:00:00 2001 From: Tianliang Zhang Date: Thu, 15 Sep 2022 16:24:41 +0200 Subject: [PATCH] Add allure-pytest tox profiles for local use When the allure-report folder is present, the default launcher for tests currently based on pytest now uses allure report related options. "allure serve tests/allure-report/" can be rund afterwards to view the report in browser. These capacities have been scripted in tox and are now used by default to ensure CI. JIRA: TRNSPRTPCE-685 Change-Id: Ic27b3efa1a77c1f2c55338861b8a6f60f9c47e02 Co-authored-by: guillaume.lambert Signed-off-by: Tianliang Zhang Signed-off-by: guillaume.lambert --- .gitignore | 3 ++- tests/launch_tests.sh | 6 +++++- tests/test-requirements.txt | 1 + tox.ini | 19 +++++++++++++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 70b203cd9..cb9c68d78 100644 --- a/.gitignore +++ b/.gitignore @@ -20,9 +20,10 @@ classes .DS_STORE .metadata ordmodels/src/main/java +tests/allure-report/ tests/config.xml tests/models -<<<<<<< HEAD +tests/test-requirements.txt *.log *.log.* __pycache__ diff --git a/tests/launch_tests.sh b/tests/launch_tests.sh index 54d1cd103..63beeb528 100755 --- a/tests/launch_tests.sh +++ b/tests/launch_tests.sh @@ -31,7 +31,11 @@ else done fi if [ -z "$LAUNCHER" ]; then - LAUNCHER="python3 -m pytest -q"; + if [ -d "allure-report" ]; then + LAUNCHER="python3 -m pytest --alluredir=allure-report/ -q" + else + LAUNCHER="python3 -m pytest -q" + fi fi for script in $scriptlist; do diff --git a/tests/test-requirements.txt b/tests/test-requirements.txt index 2049e9133..8ea5b14c7 100644 --- a/tests/test-requirements.txt +++ b/tests/test-requirements.txt @@ -1 +1,2 @@ +## Caution this file is in .gitignore pytest # MIT License diff --git a/tox.ini b/tox.ini index 075341b0c..3baf8b258 100644 --- a/tox.ini +++ b/tox.ini @@ -323,3 +323,22 @@ deps = gitlint commands = gitlint --config ../.gitlint + +[testenv:allure-report-init] +basepython = python3 +deps = allure-pytest>=2.10.0 +# allure is under Apache License 2.0 +whitelist_externals = + mkdir + sed +commands = + mkdir -p allure-report + sed -i_ '$a\allure-pytest # Apache License 2.0' ./test-requirements.txt + + +[testenv:allure-report-serve] +basepython = python3 +whitelist_externals = + allure +commands = + allure serve "allure-report" -- 2.36.6