Skip to content

captain-examples/phpunit

Repository files navigation

Getting Captain working with PHPUnit

Starting from a simple workflow that runs PHPUnit, we want to

  1. 🧪 Ensure PHPUnit produces JUnit output

phpunit --log-junit tmp/phpunit.xml will produce Captain-compatible XML output in tmp/phpunit.xml.

vendor/bin/phpunit --log-junit tmp/phpunit.xml tests/
  1. 🔐 Create an Access Token

Create an Access Token for your organization within Captain (more documentation here).

Add the new token as an action secret to your repository. Conventionally, we call this secret RWX_ACCESS_TOKEN.

  1. 💌 Install the Captain CLI, and then call it when running tests

See the full documentation on test suite integration.

- uses: rwx-research/setup-captain@v1
- run: |
    captain run \
      --suite-id captain-examples-phpunit \
      --test-results tmp/phpunit.xml \
      --language PHP \
      --framework PHPUnit \
      -- \
      vendor/bin/phpunit --log-junit tmp/phpunit.xml tests/
  env:
    RWX_ACCESS_TOKEN: ${{ secrets.RWX_ACCESS_TOKEN }}
  1. 🎉 See your test results in Captain!

Take a look at the final workflow!