Elixir collectors
To use Buildkite Test Engine with your Elixir projects, use
test_collector_elixir with ExUnit.
The recommended way to set up a new test suite is to add the Tests Buildkite plugin to the step that runs your tests. It works with every runner that bktec supports, and the entire setup is configuration-only — you can get a test suite running through changes to pipeline.yml alone, with no modifications to your application code.
Use the language-specific test collector documented on this page when you want deeper framework integration — such as custom execution tags, span annotations, or richer per-framework data. Language-specific collectors still pair well with the Tests Buildkite plugin, but adding one requires changes to your application code.
You can also upload test results by importing JSON or JUnit XML.
ExUnit
ExUnit is a Elixir unit test library.
Before you start, make sure ExUnit runs with access to CI environment variables.
Create a test suite and copy the API token that it gives you.
-
Add
buildkite_test_collectorto your list of dependencies inmix.exs:def deps do [ {:buildkite_test_collector, "~> 0.3.1", only: [:test]} ] end -
Set up your API token:
In your
config/test.exs(or other environment configuration as appropriate) add the Buildkite Test Engine API token. We suggest that you retrieve the token from the environment, and configure your CI environment accordingly (for example using secrets).import Config config :buildkite_test_collector, api_key: System.get_env("BUILDKITE_ANALYTICS_TOKEN") -
Add
BuildkiteTestCollectorFormatterto your ExUnit configuration intest/test_helper.exs:ExUnit.configure formatters: [BuildkiteTestCollector.Formatter, ExUnit.CLIFormatter] ExUnit.start -
Run your tests like normal:
Note that we attempt to detect the presence of several common CI environments. However if this fails you can set the
CIenvironment variable to any value and it will work.$ mix test ... Finished in 0.01 seconds (0.003s on load, 0.004s on tests) 3 tests, 0 failures Randomized with seed 12345 Verify that it works. If all is well, you should see the test run analytics on the Buildkite Test Engine dashboard.