diff --git a/.cursor/rules/coding.mdc b/.cursor/rules/coding.mdc index 4e6fd2538a..fbcda27b12 100644 --- a/.cursor/rules/coding.mdc +++ b/.cursor/rules/coding.mdc @@ -31,7 +31,7 @@ sentry-java is the Java and Android SDK for Sentry. This repository contains the 1. Follow existing code style and language 2. Do not modify the API files (e.g. sentry.api) manually, instead run `./gradlew apiDump` to regenerate them -3. Write comprehensive tests +3. Write comprehensive tests. For assertions in new unit tests, prefer Google Truth (`com.google.common.truth.Truth.assertThat`) over `kotlin.test`/JUnit assertions; keep `kotlin.test` for test structure like `@Test` and `assertFailsWith`. Add `testImplementation(libs.google.truth)` to a module's `build.gradle.kts` if it isn't already present. 4. New features should always be opt-in by default, extend `SentryOptions` or similar Option classes with getters and setters to enable/disable a new feature 5. Consider backwards compatibility diff --git a/AGENTS.md b/AGENTS.md index a05d938660..ec2ef62974 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -146,6 +146,8 @@ The repository is organized into multiple modules: - Write comprehensive unit tests for new features - Android modules require both unit tests and instrumented tests where applicable - System tests validate end-to-end functionality with sample applications +- **Assertions**: For new unit tests, prefer [Google Truth](https://truth.dev/) (`com.google.common.truth.Truth.assertThat`) over `kotlin.test`/JUnit assertions for its readable, fluent API. Keep using `kotlin.test` for test structure (`@Test`, `assertFailsWith`). See `sentry/src/test/java/io/sentry/DsnTest.kt` for the style. Don't rewrite existing `kotlin.test` assertions solely to switch libraries. +- Truth is wired into the `sentry` module. When adding Truth-based tests to another module, add `testImplementation(libs.google.truth)` to that module's `build.gradle.kts`. ### Contributing Guidelines 1. Follow existing code style and language