Skip to content

docs(agents): Prefer Google Truth for new unit test assertions#5735

Merged
runningcode merged 1 commit into
mainfrom
no/prefer-google-truth-in-tests
Jul 7, 2026
Merged

docs(agents): Prefer Google Truth for new unit test assertions#5735
runningcode merged 1 commit into
mainfrom
no/prefer-google-truth-in-tests

Conversation

@runningcode

Copy link
Copy Markdown
Contributor

📜 Description

Adds guidance for AI coding agents to prefer Google Truth (com.google.common.truth.Truth.assertThat) over kotlin.test/JUnit assertions when writing assertions in new unit tests, while continuing to use kotlin.test for test structure (@Test, assertFailsWith).

Updated files:

  • AGENTS.md — two bullets under Testing Requirements covering the preference, a pointer to sentry/src/test/java/io/sentry/DsnTest.kt as the reference style, and the per-module testImplementation(libs.google.truth) requirement.
  • .cursor/rules/coding.mdc — a concise version of the same guidance (this rule is alwaysApply: true).

💡 Motivation and Context

Truth (v1.4.5) is already a dependency in the sentry module and used in DsnTest.kt, but the rest of the repo uses kotlin.test. This documents Truth as the preferred choice going forward so new tests get its more readable, fluent assertions. The guidance explicitly avoids churn by not rewriting existing assertions solely to switch libraries.

💚 How did you test it?

Documentation-only change to agent instruction files. Ran ./gradlew spotlessApply apiDump with no resulting code changes.

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

As modules gain Truth-based tests, add testImplementation(libs.google.truth) to their build.gradle.kts.

#skip-changelog

Steer AI coding agents toward Google Truth's fluent assertThat API for
assertions in new unit tests, while keeping kotlin.test for test
structure. Truth is already a dependency in the sentry module; note that
other modules need testImplementation(libs.google.truth) added before
use.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sentry

sentry Bot commented Jul 7, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.47.0 (1) release

⚙️ sentry-android Build Distribution Settings

@runningcode runningcode marked this pull request as ready for review July 7, 2026 12:31
@runningcode runningcode merged commit 5f1bb66 into main Jul 7, 2026
70 checks passed
@runningcode runningcode deleted the no/prefer-google-truth-in-tests branch July 7, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants