diff --git a/Taskfile.yml b/Taskfile.yml index b5c5c1b..132d026 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -76,13 +76,19 @@ tasks: unit-test: desc: Run the unit tests + vars: + # If CLI_ARGS are set, append them as an "and" after the -m unit + MARK_EXPR: unit{{if .CLI_ARGS}} and {{.CLI_ARGS}}{{end}} cmds: - - '{{.RUN_SCRIPT}} pytest --keep-baked-projects -m unit tests/' + - '{{.RUN_SCRIPT}} pytest --keep-baked-projects -m "{{.MARK_EXPR}}" tests/' integration-test: desc: Run the integration tests + vars: + # If CLI_ARGS are set, append them as an "and" after the -m integration + MARK_EXPR: integration{{if .CLI_ARGS}} and {{.CLI_ARGS}}{{end}} cmds: - - '{{.RUN_SCRIPT}} pytest --keep-baked-projects -m integration tests/' + - '{{.RUN_SCRIPT}} pytest --keep-baked-projects -m "{{.MARK_EXPR}}" tests/' update: desc: Update the project dev and runtime dependencies diff --git a/docs/testing.md b/docs/testing.md index f6c496d..e76c5e5 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -20,6 +20,12 @@ task unit-test # Run unit tests only task integration-test # Run integration tests only ``` +If you'd like to exclude tests that are marked a certain way, you can pass additional details to the above tasks, for instance: + +```bash +task test -- "not slow" # Skip slow tests +``` + ### What Template Tests Cover - **Generation Validation**: Tests with various input combinations to ensure valid project generation diff --git a/tests/test_cookiecutter.py b/tests/test_cookiecutter.py index f786177..59c53aa 100755 --- a/tests/test_cookiecutter.py +++ b/tests/test_cookiecutter.py @@ -212,6 +212,7 @@ def test_autofix_hook(cookies, context): @pytest.mark.integration +@pytest.mark.slow def test_default_project(cookies): """ Test a default project thoroughly diff --git "a/{{cookiecutter.project_name|replace(\" \", \"\")}}/.github/CONTRIBUTING.md" "b/{{cookiecutter.project_name|replace(\" \", \"\")}}/.github/CODE_OF_CONDUCT.md" similarity index 100% rename from "{{cookiecutter.project_name|replace(\" \", \"\")}}/.github/CONTRIBUTING.md" rename to "{{cookiecutter.project_name|replace(\" \", \"\")}}/.github/CODE_OF_CONDUCT.md" diff --git "a/{{cookiecutter.project_name|replace(\" \", \"\")}}/Taskfile.yml" "b/{{cookiecutter.project_name|replace(\" \", \"\")}}/Taskfile.yml" index 3cb6af8..bbafbea 100644 --- "a/{{cookiecutter.project_name|replace(\" \", \"\")}}/Taskfile.yml" +++ "b/{{cookiecutter.project_name|replace(\" \", \"\")}}/Taskfile.yml" @@ -164,17 +164,23 @@ tasks: unit-test: desc: Run the project unit tests deps: ["coverage-erase"] + vars: + # If CLI_ARGS are set, append them as an "and" after the -m unit + MARK_EXPR: unit{{ '{{if .CLI_ARGS}}' }} and {{ '{{.CLI_ARGS}}{{end}}' }} cmds: - - '{{ '{{.RUN_SCRIPT}}' }} pytest -m unit tests/' + - '{{ '{{.RUN_SCRIPT}}' }} pytest -m "{{ '{{.MARK_EXPR}}' }}" tests/' integration-test: desc: Run the project integration tests deps: ["coverage-erase"] + vars: + # If CLI_ARGS are set, append them as an "and" after the -m integration + MARK_EXPR: integration{{ '{{if .CLI_ARGS}}' }} and {{ '{{.CLI_ARGS}}{{end}}' }} status: # Only run integration tests when the PLATFORM is set to all or the same platform as we're running on - '{{ '{{if or (eq .PLATFORM "all") (eq .PLATFORM .LOCAL_PLATFORM) (not .PLATFORM)}}' }}exit 1{{ '{{else}}' }}exit 0{{ '{{end}}' }}' cmds: - - '{{ '{{.RUN_SCRIPT}}' }} pytest -m integration tests/' + - '{{ '{{.RUN_SCRIPT}}' }} pytest -m "{{ '{{.MARK_EXPR}}' }}" tests/' update: desc: Update the project dev and runtime dependencies diff --git "a/{{cookiecutter.project_name|replace(\" \", \"\")}}/tests/test_integration.py" "b/{{cookiecutter.project_name|replace(\" \", \"\")}}/tests/test_integration.py" index c0e6153..39920c2 100755 --- "a/{{cookiecutter.project_name|replace(\" \", \"\")}}/tests/test_integration.py" +++ "b/{{cookiecutter.project_name|replace(\" \", \"\")}}/tests/test_integration.py" @@ -13,6 +13,7 @@ @pytest.mark.integration +@pytest.mark.slow def test_project_tasks(): """ Test the project's task runner commands work together properly.