Test Analytics
Learn about how Sentry Prevent's Test Analytics tools can help you improve your code.
Sentry Prevent Test Analytics provides actionable insights into your CI test runs, helping you identify flaky tests, track failures, and optimize your test suite for faster, more reliable deployments.
- Spot Flaky Tests: Quickly identify and address tests that fail intermittently, reducing noise and wasted debugging time.
- Track Failures and Trends: Monitor cumulative failures, slowest tests, and overall test run efficiency to improve CI reliability.
- Actionable Insights: See which lines of code failed within tests, confirm flaky tests, and prioritize fixes.
- Integrated with Sentry: Access test analytics alongside your error and performance data for a unified developer experience.
Sentry Prevent Test Analytics is currently in beta. Beta features are still a work in progress and may have bugs.
To use Sentry Prevent Test Analytics, you’ll need to install the Sentry app on your GitHub organization or specific repositories. Once installed, choose your JUnit XML Report framework and set your permissions using a repository secret.
The only test result file format we support is JUnit XML. Most test frameworks support outputting test results in this format, with some configuration.
Each testing framework will have slight differences in the JUnit XML format it outputs, but we aim to support all of them.
There are two ways to upload your test results:
If you are already using GitHub Actions, you can use the getsentry/prevent-action
script to upload your test results.
- name: Upload test results to Sentry
if: ${{ !cancelled() }}
uses: getsentry/prevent-action
with:
token: ${{ secrets.SENTRY_PREVENT_TOKEN }}
Sentry Prevent’s CLI to Upload Testing Reports
If you do not use Github Actions, install the Sentry Prevent CLI using pip install sentry-prevent-cli
(for Python), or use a binary platform.
curl -L https://github.com/getsentry/sentry-prevent-cli/releases/latest/download/sentry-prevent-cli-macos -o sentry-prevent-cli
chmod +x sentry-prevent-cli
Then, upload your test results using the CLI:
sentry-prevent-cli db upload --report-type test_results --file <report_name>.junit.xml
Now that you've configured your CI to upload your test results, you can inspect the workflow logs to see if the call to Sentry succeeded. You need to have some failed tests to view the failed tests report.
After your workflow runs, view failed tests in the failed tests dashboard, or in your GitHub pull request comments.
You can see a complete overview of your test analytics in the test analytics dashboard.
When configuring Test Analytics, you'll be asked to choose your upload permissions. For GitHub Actions, you can use OpenID Connect, or generate a repository token. Using the CLI, generate a repository token.
You can find a list of repository tokens on the Sentry Prevent tokens page.
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").