ExUnit
doesn't natively support writing output to a file, but you can use a reporter to produce JUnit output.
- Add
:junit_formatter
to your deps mix deps.get
- Add
ExUnit.configure formatters: [JUnitFormatter, ExUnit.CLIFormatter]
intest/test_helper.exs
- Configure the reporter as we have in this repo
With these changes, ExUnit
will produce Captain-compatible XML output in the tmp/junit
directory.
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
.
See the full documentation on test suite integration. Use a glob when specifying --test-results
since the JUnit reporter will write files named dynamically with our configuration. You'll also need to specify --language Elixir
and --framework ExUnit
to inform the Captain CLI about how to interpret the test result files.
- uses: rwx-research/setup-captain@v1
- name: Run tests
run: |
captain run \
--suite-id captain-examples-exunit \
--test-results "tmp/junit/*.xml" \
--language Elixir \
--framework ExUnit \
-- mix test
env:
RWX_ACCESS_TOKEN: ${{ secrets.RWX_ACCESS_TOKEN }}
Take a look at the final workflow!