Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/test_cookiecutter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions {{cookiecutter.project_name|replace(" ", "")}}/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


@pytest.mark.integration
@pytest.mark.slow
def test_project_tasks():
"""
Test the project's task runner commands work together properly.
Expand Down
Loading