Configuring Golang with Test Analytics

To use Test Analytics with your Golang projects, generate JUnit XML files with gotestsum, and 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 go testsum, 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.