We've recently updated the navigation
You can find APIs and Integrations in their own sections in the horizontal menu bar at the top of the page.
Elixir Collectors
Test Analytics ships with a ExUnit test collector
test_collector_elixir
.
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_collector
to your list of dependencies inmix.exs
:def deps do [ {:buildkite_test_collector, "~> 0.1.0", only: [:test]} ] end
-
Set up your API token:
In your
config/test.exs
(or other environment configuration as appropriate) add the analytics 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
BuildkiteTestCollectorFormatter
to 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
CI
environment 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 in the test analytics section of the Buildkite dashboard.