Skip to content

Commit

Permalink
[n/a] Update testing docs. Add codecept helpers (#86)
Browse files Browse the repository at this point in the history
* [n/a] Update testing docs. Add codecept helpers

* [n/a] Lock Mysql version to fix failing codecept action

See: craftcms/.github@923aaf7
  • Loading branch information
joshuapease authored May 25, 2024
1 parent fb7bc2c commit 8def173
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .ddev/commands/web/codecept.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Usage: codecept
## Description: Run codeception for this project
vendor/bin/codecept "$@"
2 changes: 1 addition & 1 deletion .github/workflows/codecept.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
# Install MySQL
mysql:
image: bitnami/mysql:latest
image: bitnami/mysql:8.0.37
env:
MYSQL_ROOT_PASSWORD: mysecretpassword
MYSQL_DATABASE: craft_test
Expand Down
10 changes: 10 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@ modules:
cleanup: true
transaction: true
dbSetup: { clean: true, setupCraft: true }
env:
# Call codecept run <command> --env fast
# Skips slow DB tasks. Test must be run without the --env
# flag at least once before this will work properly.
fast:
modules:
config:
\craft\test\Craft:
# Don't clean out the database
dbSetup: { clean: false, setupCraft: false, applyMigrations: false }
30 changes: 22 additions & 8 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,32 @@ nav_order: 7

# Testing

This repo utilizes Docker in order to run the test suite.
This repo utilizes DDEV in order to run the test suite locally.

1. Install [Docker Desktop for Mac](https://docs.docker.com/docker-for-mac/install/).
Tests are run in GitHub Actions when PRs are opened.

2. Build the containers
### Install DDEV
[DDEV](https://ddev.com/).

Run `docker-compose build`. This will take a little while.
### Launch DDEV
```
ddev start
```

3. Run the app
### Run the tests

Run `docker-compose up`.
```
# Run all tests
ddev codecept run unit
4. Run the tests
# Run specific test
ddev codecept run unit PartsKitTest
Run `bin/codecept run`
# Run without database setup (must run without env flag first)
ddev codecept run unit PartsKitTest --env fast
```

Run specific tests
```
```

0 comments on commit 8def173

Please sign in to comment.