> ## Documentation Index
> Fetch the complete documentation index at: https://trunk-4cab4936-mintlify-73ee825c.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# GoogleTest

> A guide for generating Trunk-compatible test reports for GoogleTest

You can automatically [detect and manage flaky tests](../../detection/) in your GoogleTest projects by integrating with Trunk. This document explains how to configure GoogleTest to output JUnit XML reports that can be uploaded to Trunk for analysis.

## Setup steps

Work through the steps below in order. Once you've finished the last one, you'll be ready to move on to [configure uploads in CI](../ci-providers/).

<Steps>
  <Step title={<a href="#generating-reports">Generate a compatible test report</a>} />

  <Step title={<a href="#report-file-path">Configure the report file path or glob</a>} />

  <Step title={<a href="#disable-retries">Disable retries for better detection accuracy</a>} />

  <Step title={<a href="#try-it-locally">Test uploads locally</a>} />
</Steps>

## Generating Reports

Before you can integrate with Trunk, you need to generate a Trunk-compatible report. For GoogleTest, the built in XML reporter will work. You can use the [`--gtest_output=xml`](https://google.github.io/googletest/advanced.html#generating-an-xml-report) argument when you run your built test project:

```shell theme={null}
./build/run_test --gtest_output=xml
```

### Report File Path

By default, the JUnit report will be written to a `test_detail.xml` file.

You can specify a custom directory and filename with:

```bash theme={null}
--gtest_output=xml:<path/to/file.xml>
```

For example, the following argument writes a JUnit report to `./junit.xml`:

```bash theme={null}
--gtest_output=xml:junit.xml
```

### Disable Retries

You need to disable automatic retries if you previously enabled them. Retries compromise the accurate detection of flaky tests.

Omit the[ ](https://docs.pytest.org/en/stable/how-to/cache.html)[`--gtest_repeat`](https://google.github.io/googletest/advanced.html#repeating-the-tests) argument if you've previously configured your CI with these options to disable retries.

## Try It Locally

### The Validate Command

<CodeGroup>
  ```bash Linux (x64) theme={null}
  SKU="trunk-analytics-cli-x86_64-unknown-linux.tar.gz"
  curl -fL --retry 3 \
    "https://github.com/trunk-io/analytics-cli/releases/latest/download/${SKU}" \
    | tar -xz

  chmod +x trunk-analytics-cli
  ./trunk-analytics-cli validate --junit-paths "./junit.xml"
  ```

  ```bash Linux (arm64) theme={null}
  SKU="trunk-analytics-cli-aarch64-unknown-linux.tar.gz"
  curl -fL --retry 3 \
    "https://github.com/trunk-io/analytics-cli/releases/latest/download/${SKU}" \
    | tar -xz

  chmod +x trunk-analytics-cli
  ./trunk-analytics-cli validate --junit-paths "./junit.xml"
  ```

  ```bash macOS (arm64) theme={null}
  SKU="trunk-analytics-cli-aarch64-apple-darwin.tar.gz"
  curl -fL --retry 3 \
    "https://github.com/trunk-io/analytics-cli/releases/latest/download/${SKU}" \
    | tar -xz

  chmod +x trunk-analytics-cli
  ./trunk-analytics-cli validate --junit-paths "./junit.xml"
  ```

  ```bash macOS (x64) theme={null}
  SKU="trunk-analytics-cli-x86_64-apple-darwin.tar.gz"
  curl -fL --retry 3 \
    "https://github.com/trunk-io/analytics-cli/releases/latest/download/${SKU}" \
    | tar -xz

  chmod +x trunk-analytics-cli
  ./trunk-analytics-cli validate --junit-paths "./junit.xml"
  ```
</CodeGroup>

### Test Upload

Before modifying your CI jobs to automatically upload test results to Trunk, try uploading a single test run manually.

You make an upload to Trunk using the following command:

```sh theme={null}
./trunk-analytics-cli upload --junit-paths "./junit.xml" \
    --org-url-slug <TRUNK_ORG_URL_SLUG> \
    --token <TRUNK_ORG_TOKEN>
```

## Next Steps

Configure your CI to upload test runs to Trunk. Find the guides for your CI framework below:

<Columns cols={3}>
  <Card title="Azure DevOps Pipelines" href="../ci-providers/azure-devops-pipelines" img="https://mintcdn.com/trunk-4cab4936-mintlify-73ee825c/3r09RzSULJ9MTpKT/assets/_shared/azure.png?fit=max&auto=format&n=3r09RzSULJ9MTpKT&q=85&s=3e813ca204880aa4b9758b0c330509d2" width="1600" height="1000" data-path="assets/_shared/azure.png" />

  <Card title="BitBucket Pipelines" href="../ci-providers/bitbucket-pipelines" img="https://mintcdn.com/trunk-4cab4936-mintlify-73ee825c/3r09RzSULJ9MTpKT/assets/_shared/bitbucket.png?fit=max&auto=format&n=3r09RzSULJ9MTpKT&q=85&s=6159b4bb79eb337f072288f80299826e" width="1600" height="1000" data-path="assets/_shared/bitbucket.png" />

  <Card title="BuildKite" href="../ci-providers/buildkite" img="https://mintcdn.com/trunk-4cab4936-mintlify-73ee825c/3r09RzSULJ9MTpKT/assets/_shared/buildkite.png?fit=max&auto=format&n=3r09RzSULJ9MTpKT&q=85&s=cb06611f488a4d11fd4ea96391cf029b" width="1600" height="1000" data-path="assets/_shared/buildkite.png" />

  <Card title="CircleCI" href="../ci-providers/circleci" img="https://mintcdn.com/trunk-4cab4936-mintlify-73ee825c/3r09RzSULJ9MTpKT/assets/_shared/circle-ci.png?fit=max&auto=format&n=3r09RzSULJ9MTpKT&q=85&s=f33dbd4656eca58bd1900af983f7adbc" width="1600" height="1000" data-path="assets/_shared/circle-ci.png" />

  <Card title="Drone CI" href="../ci-providers/droneci" img="https://mintcdn.com/trunk-4cab4936-mintlify-73ee825c/3r09RzSULJ9MTpKT/assets/_shared/drone.png?fit=max&auto=format&n=3r09RzSULJ9MTpKT&q=85&s=00d6473c3d1a2733f2a1b6a4ba398d13" width="1600" height="1000" data-path="assets/_shared/drone.png" />

  <Card title="GitHub Actions" href="../ci-providers/github-actions" img="https://mintcdn.com/trunk-4cab4936-mintlify-73ee825c/3r09RzSULJ9MTpKT/assets/_shared/github.png?fit=max&auto=format&n=3r09RzSULJ9MTpKT&q=85&s=c0cc2772377cb47ac0823976f3c5620c" width="1600" height="1000" data-path="assets/_shared/github.png" />

  <Card title="GitLab" href="../ci-providers/gitlab" img="https://mintcdn.com/trunk-4cab4936-mintlify-73ee825c/3r09RzSULJ9MTpKT/assets/_shared/gitlab.png?fit=max&auto=format&n=3r09RzSULJ9MTpKT&q=85&s=881497ec1791445462d41697e313690b" width="1600" height="1000" data-path="assets/_shared/gitlab.png" />

  <Card title="Jenkins" href="../ci-providers/jenkins" img="https://mintcdn.com/trunk-4cab4936-mintlify-73ee825c/3r09RzSULJ9MTpKT/assets/_shared/jenkins.png?fit=max&auto=format&n=3r09RzSULJ9MTpKT&q=85&s=7411c4db9a0650863022bda380c52022" width="1600" height="1000" data-path="assets/_shared/jenkins.png" />

  <Card title="Semaphore" href="../ci-providers/semaphoreci" img="https://mintcdn.com/trunk-4cab4936-mintlify-73ee825c/3r09RzSULJ9MTpKT/assets/_shared/semaphore.png?fit=max&auto=format&n=3r09RzSULJ9MTpKT&q=85&s=a55bad39db53bd369d645d3d800744ef" width="1600" height="1000" data-path="assets/_shared/semaphore.png" />

  <Card title="TeamCity" img="https://mintcdn.com/trunk-4cab4936-mintlify-73ee825c/3r09RzSULJ9MTpKT/assets/_shared/teamcity.png?fit=max&auto=format&n=3r09RzSULJ9MTpKT&q=85&s=f5b4738f643ed0a0059c97b1f5f086f1" width="1600" height="1000" data-path="assets/_shared/teamcity.png" />

  <Card title="Travis CI" href="../ci-providers/travisci" img="https://mintcdn.com/trunk-4cab4936-mintlify-73ee825c/3r09RzSULJ9MTpKT/assets/_shared/travis.png?fit=max&auto=format&n=3r09RzSULJ9MTpKT&q=85&s=9ffdeed7a98629ad13083586826a8b1e" width="1600" height="1000" data-path="assets/_shared/travis.png" />

  <Card title="Other CI Providers" href="../ci-providers/otherci" img="https://mintcdn.com/trunk-4cab4936-mintlify-73ee825c/3r09RzSULJ9MTpKT/assets/_shared/other.png?fit=max&auto=format&n=3r09RzSULJ9MTpKT&q=85&s=e77722a0d5a16b1df891709fed5d2c2c" width="1600" height="1000" data-path="assets/_shared/other.png" />
</Columns>
