diff --git a/.ddev/commands/web/codecept.sh b/.ddev/commands/web/codecept.sh new file mode 100755 index 0000000..4e42a06 --- /dev/null +++ b/.ddev/commands/web/codecept.sh @@ -0,0 +1,3 @@ +## Usage: codecept +## Description: Run codeception for this project +vendor/bin/codecept "$@" diff --git a/.github/workflows/codecept.yml b/.github/workflows/codecept.yml index 2f21fc2..3553e22 100644 --- a/.github/workflows/codecept.yml +++ b/.github/workflows/codecept.yml @@ -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 diff --git a/codeception.yml b/codeception.yml index 8b2afa1..9476b39 100644 --- a/codeception.yml +++ b/codeception.yml @@ -21,3 +21,13 @@ modules: cleanup: true transaction: true dbSetup: { clean: true, setupCraft: true } +env: + # Call codecept run --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 } diff --git a/docs/testing.md b/docs/testing.md index cffc288..d8719ce 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -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 +``` +```