Rust Collector

Test Analytics ships with a Rust collector :github: test-collector-rust.

You can also upload test results by importing JSON or JUnit XML.

Before you start, make sure Rust runs with access to CI environment variables.

  1. Create a test suite and copy the API token that it gives you.

  2. Install the buildkite-test-collector crate:

    $ cargo install buildkite-test-collector
    # or
    $ cargo install --git buildkite-test-collector
  3. Configure your environment:

    Set the BUILDKITE_ANALYTICS_TOKEN environment variable to contain the token provided by the analytics project settings.

    We try and detect several common CI environments based in the environment variables which are present. If this detection fails then the application will crash with an error. To force the use of a "generic CI environment" set the CI environment variable to any non-empty value.

  4. Change your test output to JSON format:

    In your CI environment you will need to change your output format to JSON and add --report-time to include execution times in the output. Unfortunately, these are currently unstable options for Rust, so some extra command line options are needed. Once you have the JSON output you can pipe it through the buildkite-test-collector binary - the input JSON is echoed back to STDOUT so that you can still operate upon it if needed.

    $ cargo test -- -Z unstable-options --format json --report-time | buildkite-test-collector
  5. Confirm correct operation. Verify that the run is visible in the Buildkite analytics dashboard