unittest
doesn't natively support writing output to a file, but you can use unittest-xml-reporting
as your test runner to produce junit output without having to modify your tests at all.
pip install unittest-xml-reporting
python -m xmlrunner -o tmp
will produce Captain-compatible xml output in the tmp/
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 unittest-xml-reporting
will write multiple files by default. You'll also need to specify --language Python
and --framework unittest
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-unittest \
--test-results tmp/*.xml \
--language Python \
--framework unittest \
-- python -m xmlrunner -o tmp
env:
RWX_ACCESS_TOKEN: ${{ secrets.RWX_ACCESS_TOKEN }}
Take a look at the final workflow!