diff --git a/.github/workflows/pandora2d_ci.yml b/.github/workflows/pandora2d_ci.yml index a42d89e..5d3fbb2 100644 --- a/.github/workflows/pandora2d_ci.yml +++ b/.github/workflows/pandora2d_ci.yml @@ -23,6 +23,7 @@ jobs: pip install pytest pip install pytest-cov pip install pytest-mock + pip install pytest-html pip install codecov pip install build - name: Install Pandora2d @@ -31,7 +32,8 @@ jobs: - name: Test with pytest run: | export NUMBA_DISABLE_JIT="1" - pytest --junitxml=pytest-report.xml --cov-config=.coveragerc --cov-report xml --cov + pytest -m "unit_tests" --html=unit-test-report.html --cov-config=.coveragerc --cov-report xml --cov + pytest -m "functional_tests" --html=functional-test-report.html - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 - name: Create source distrubition diff --git a/Makefile b/Makefile index e323e58..85717a8 100644 --- a/Makefile +++ b/Makefile @@ -69,24 +69,24 @@ test-all: install test-unit test-functional test-resource test-performance ## ru .PHONY: test-unit test-unit: install ## run unit tests only (for dev) + coverage (source venv before) @echo "Run unit tests" - @${PANDORA2D_VENV}/bin/pytest -m "unit_tests" --junitxml=pytest-report.xml --cov-config=.coveragerc --cov-report xml --cov + @${PANDORA2D_VENV}/bin/pytest -m "unit_tests" --html=unit-test-report.html --cov-config=.coveragerc --cov-report xml --cov .PHONY: test-functional test-functional: install ## run functional tests only (for dev and validation plan) @echo "Run functional tests" - @${PANDORA2D_VENV}/bin/pytest -m "functional_tests" + @${PANDORA2D_VENV}/bin/pytest -m "functional_tests" --html=functional-test-report.html .PHONY: test-resource test-resource: install ## run resource tests only (for validation plan) @echo "Run resource tests" @rm -f tests/resource_tests/.pymon @${PANDORA2D_VENV}/bin/pytest -m "resource_tests and not metrics" --db tests/resource_tests/.pymon - @${PANDORA2D_VENV}/bin/pytest tests/resource_tests/test_metrics.py --database tests/resource_tests/.pymon + @${PANDORA2D_VENV}/bin/pytest tests/resource_tests/test_metrics.py --database tests/resource_tests/.pymon --html=resource-test-report.html .PHONY: test-performance test-performance: install ## run performance tests only (for validation plan) @echo "Run performance tests" - @${PANDORA2D_VENV}/bin/pytest -m "performance_tests" + @${PANDORA2D_VENV}/bin/pytest -m "performance_tests" --html=performance-test-report.html ## Code quality, linting section @@ -182,11 +182,11 @@ clean-test: @rm -rf coverage.xml @rm -fr htmlcov/ @rm -fr .pytest_cache - @rm -f pytest-report.xml @rm -f pylint-report.txt @rm -f debug.log @rm -f .pymon @rm -f tests/resource_tests/.pymon + @rm -f *-test-report.html .PHONY: clean-doc clean-doc: diff --git a/pytest.ini b/pytest.ini index f881924..84f2eed 100644 --- a/pytest.ini +++ b/pytest.ini @@ -6,4 +6,5 @@ markers = functional_tests: functional tests resource_tests: resource tests performance_tests: accuracy tests -norecursedirs = .git doc conf .gitlab \ No newline at end of file +norecursedirs = .git doc conf .gitlab +generate_report_on_test = True \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 2d78650..1d053dc 100644 --- a/setup.cfg +++ b/setup.cfg @@ -78,6 +78,7 @@ dev = pytest-cov pytest-mock pytest-monitor + pytest-html pre-commit isort>=5.8.0 # Check imports black>=21.5b0 # PEP8 format code diff --git a/tests/conftest.py b/tests/conftest.py index 750c25a..9428ca5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Centre National d'Etudes Spatiales (CNES). +# Copyright (c) 2024 Centre National d'Etudes Spatiales (CNES). # # This file is part of PANDORA2D # @@ -21,6 +21,7 @@ """ import pathlib +import re import pytest @@ -46,6 +47,33 @@ def pytest_collection_modifyitems(config, items): item.add_marker(pytest.mark.monitor_skip_test) +def pytest_html_results_table_header(cells): + """ + Add columns to html reports: + + 1. Category : with values {'TU', 'TF', 'TP', 'TR'} + 2. Function tested : basename of python test file + """ + cells.insert(1, "