/xunit2

How to integrate Captain with xUnit

Primary LanguageC#MIT LicenseMIT

Getting Captain working with xUnit

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

1. ๐Ÿงช Ensure xUnit produces xUnit-xml output

Ensure your project includes the XunitXml.TestLogger test logger

dotnet add package XunitXml.TestLogger --version 3.0.70

And use it with xunit test --logger xunit. Note: you can also change the outputted filename.

dotnet test --logger "xunit;LogFileName=TestResults.xml" --results-directory "TestResults"

Note: We've specified the filename and results directory here, however TestResults/TestResults.xml is also the default result path

2. ๐Ÿ” 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.

3. ๐Ÿ’Œ Install the Captain CLI, and call it when running tests

See the full documentation on test suite integration.

- uses: rwx-research/setup-captain@v1
- name: Run tests
  run: |
    captain run \
      --suite-id captian-examples-xunit2 \
      --test-results TestResults/TestResults.xml \
      -- dotnet test --logger "xunit;LogFileName=TestResults.xml" --results-directory "TestResults"
  env:
    RWX_ACCESS_TOKEN: ${{ secrets.RWX_ACCESS_TOKEN }}

4. ๐ŸŽ‰ See your test results in Captain!

Take a look at the final workflow!