Configuring Go with Test Analytics

To use Test Analytics with your Go language projects use gotestsum to generate JUnit XML files, then upload the JUnit XML files to Test Analytics.

  1. Install gotestsum:

    go install
  2. Use gotestsum to run your tests and output JUnit XML, by replacing go test with gotestsum, for example:

    gotestsum --junitfile junit.xml ./...
  3. Upload the JUnit.xml to Buildkite:

    curl \
      -X POST \
      --fail-with-body \
      -H "Authorization: Token token=\"$BUILDKITE_ANALYTICS_TOKEN\"" \
      -F "data=@junit.xml" \
      -F "format=junit" \
      -F "run_env[CI]=buildkite" \
      -F "run_env[key]=$BUILDKITE_BUILD_ID" \
      -F "run_env[number]=$BUILDKITE_BUILD_NUMBER" \
      -F "run_env[job_id]=$BUILDKITE_JOB_ID" \
      -F "run_env[branch]=$BUILDKITE_BRANCH" \
      -F "run_env[commit_sha]=$BUILDKITE_COMMIT" \
      -F "run_env[message]=$BUILDKITE_MESSAGE" \
      -F "run_env[url]=$BUILDKITE_BUILD_URL" \

See gotestsum for full documentation of its features and command-line flags.