diff --git a/pyproject.toml b/pyproject.toml index 49d41fdce7..2934a67e7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,12 +55,10 @@ line_length = 88 minversion = "7.0" testpaths = "tests" xfail_strict = true -addopts = [ - "--cov", -] [tool.coverage.run] branch = true +parallel = true omit = ["tests/**"] [tool.coverage.report] diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/integration/test_init.py b/tests/integration/test_init.py new file mode 100644 index 0000000000..2a406eb390 --- /dev/null +++ b/tests/integration/test_init.py @@ -0,0 +1,25 @@ +# This file is part of starcraft. +# +# Copyright 2023 Canonical Ltd. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 3, as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, +# SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +"""Basic Starcraft package demo tests.""" +import subprocess + + +def test_cli(): + expected = "Hello *craft team!\n" + + actual = subprocess.check_output(["starcraft-hello"], text=True) + + assert expected == actual diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/test_init.py b/tests/unit/test_init.py similarity index 95% rename from tests/test_init.py rename to tests/unit/test_init.py index 61c5974195..78d4114a4d 100644 --- a/tests/test_init.py +++ b/tests/unit/test_init.py @@ -13,7 +13,7 @@ # # You should have received a copy of the GNU General Public License along # with this program. If not, see . -"""Basic Starcraft package demo tests.""" +"""Basic Starcraft package demo unit tests.""" from unittest import mock from starcraft import hello diff --git a/tox.ini b/tox.ini index eb7d09a453..192ffb6e2b 100644 --- a/tox.ini +++ b/tox.ini @@ -27,15 +27,25 @@ env_tmp_dir = {user_tmp_dir:{env:XDG_RUNTIME_DIR:{work_dir}}}/tox_tmp/{env_name} set_env = TMPDIR={env_tmp_dir} -[testenv:test-{py38,py39,py310,py311,py312}] # Configuration for all tests using pytest -description = Run tests with pytest +[test] # Base configuration for unit and integration tests package = sdist extras = dev -labels = - py38, py310, py311: tests, unit-tests allowlist_externals = mkdir commands_pre = mkdir -p results -commands = pytest {tty:--color=yes} --cov-report=xml:results/coverage-{env_name}.xml --junit-xml=results/test-results-{env_name}.xml {posargs} + +[testenv:test-{py38,py39,py310,py311,py312}] # Configuration for all tests using pytest +base = testenv, test +description = Run unit tests with pytest +labels = + py38, py310, py311: tests, unit-tests +commands = pytest {tty:--color=yes} --cov --cov-report=xml:results/coverage-{env_name}.xml --junit-xml=results/test-results-{env_name}.xml tests/unit {posargs} + +[testenv:integration-{py38,py39,py310,py311,py312}] +base = testenv, test +description = Run integration tests with pytest +labels = + py38, py310, py311: tests, integration-tests +commands = pytest {tty:--color=yes} --junit-xml=results/test-results-{env_name}.xml tests/integration {posargs} [lint] # Standard linting configuration skip_install = true