RWX

RWX and Captain work together to run your tests and provide you with test result data directly in RWX.

Here, we'll walk through everything needed to integrate Captain with RWX:

  1. Installing the Captain CLI
  2. Integrating Captain with your test framework
  3. Retry failed tests from RWX

Installing Captain

Add a task that uses the rwx/install-captain package to install the Captain CLI.

# .rwx/ci.yml

tasks:
  - key: captain
    call: rwx/install-captain 1.0.2

Integrating Captain with your test framework

Captain integrates with many test frameworks. [Find instructions for your specific test framework here.][captain-test-frameworks]

This example integrates with [Ruby's RSpec][ruby-rspec] but can be used as a baseline for integrating with a different framework.

# .captain/config.yml

test-suites:
  captain-examples-rspec:
    command: bundle exec rspec --format json --out rspec-results.json --format progress
    results:
      path: rspec-results.json
    output:
      print-summary: true
      reporters:
        rwx-v1-json: captain-results.json
# .rwx/ci.yml

tasks:
  # ... tasks that clone your repo, setup Ruby, etc. here
  - key: captain
    call: rwx/install-captain 1.0.2

  - key: rspec
    use: captain # you'll likely also depend on your code, your Ruby dependencies, etc.
    run: captain run captain-examples-rspec
    outputs:
      test-results:
        - path: captain-results.json

Partitioning

Captain's partitioning feature works with RWX parallel tasks:

Start by updating your Captain configuration to enable partitioning as follows:

# .captain/config.yml

test-suites:
  captain-examples-rspec:
    # existing config...
    partition:
      command: bundle exec rspec --format json --out tmp/rspec.json --format progress {{ testFiles }}
      globs:
        - spec/**/*_spec.rb

And then use the parallel expressions to instruct Captain to run individual partitions.

# .rwx/ci.yml

tasks:
  # ... tasks that clone your repo, setup Ruby, etc. here
  - key: captain
    call: rwx/install-captain 1.0.2

  - key: rspec
    use: captain # you'll likely also depend on your code, your Ruby dependencies, etc.
    parallel: 2
    run: captain run captain-examples-rspec --partition-index ${{ parallel.index }} --partition-total ${{ paralllel.total }}
    outputs:
      test-results:
        - path: test-results.json

Viewing test results

RWX will display your test results directly in the UI:

test results in RWX

Captain will also automatically output an RWX link linking to your test results inside of Captain, and the results in Captain will link back to RWX.

Retrying failed tests

If you configure Captain with a retry command, Captain will add a retry action to RWX allowing you to retry only the tests that failed.