You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 408c89a
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: .claude/skills/test/SKILL.md
+17-22Lines changed: 17 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,14 @@
1
1
---
2
2
name: test
3
-
description: Run tests for a specific SDK module. Use when asked to "run tests", "test module", "run unit tests", "run system tests", "run e2e tests", or test a specific class. Auto-detects unit vs system tests. Supports interactive mode.
3
+
description: Run tests for a specific SDK module. Use when asked to "run tests", "test module", "run unit tests", "run integration tests", "run e2e tests", or test a specific class. Auto-detects unit tests vs integration test suites. Supports interactive mode.
Run tests for a specific module. Auto-detects whether to run unit tests or system tests.
10
+
Run tests for a specific module. Auto-detects whether to run unit tests or an integration test
11
+
suite.
11
12
12
13
## Step 0: Check for Interactive Mode
13
14
@@ -19,7 +20,7 @@ In interactive mode, use AskUserQuestion at decision points as described in the
19
20
20
21
The argument can be either:
21
22
- A **file path** (e.g., `@sentry/src/test/java/io/sentry/ScopesTest.kt`)
22
-
- A **module name** (e.g., `sentry-android-core`, `sentry-samples-spring-boot-4`)
23
+
- A **module name** (e.g., `sentry-android-core`, `sentry-spring-boot-4`)
23
24
- A **module name + test filter** (e.g., `sentry ScopesTest`)
24
25
25
26
Extract the module name and optional test class filter from the argument.
@@ -30,10 +31,14 @@ Extract the module name and optional test class filter from the argument.
30
31
31
32
| Signal | Test Type |
32
33
|--------|-----------|
33
-
| Path contains `sentry-samples/`| System test |
34
-
| Module name starts with `sentry-samples-`| System test |
34
+
| Path contains `/src/integrationTest*/` or `/src/agentFixture/`| Integration test suite |
35
+
| Module name only, and the user asks for integration or end-to-end tests | Integration test suite: each `src/integrationTest*/` directory of the module |
36
+
| Path contains `sentry-samples/`, or module name starts with `sentry-samples-`| None: samples have no tests |
35
37
| Everything else | Unit test |
36
38
39
+
For a sample, tell the user that samples have no tests, and that the end-to-end tests for what
40
+
the sample shows live in the module it uses (see the `e2e_tests` rule).
41
+
37
42
## Step 3a: Run Unit Tests
38
43
39
44
Determine the Gradle test task:
@@ -60,30 +65,20 @@ Without a filter:
60
65
./gradlew ':<module>:<task>' --info
61
66
```
62
67
63
-
## Step 3b: Run System Tests
64
-
65
-
System tests require the Python-based test runner which manages a mock Sentry server and sample app lifecycle.
66
-
67
-
1. Ensure the Python venv exists:
68
-
```bash
69
-
test -d .venv || make setupPython
70
-
```
68
+
## Step 3b: Run an Integration Test Suite
71
69
72
-
2. Extract the sample module name. For file paths like `sentry-samples/<sample-module>/src/...`, the sample module is the directory name (e.g., `sentry-samples-spring`).
70
+
The suite's task is named after its source set directory: `src/integrationTestWebflux/...` runs
71
+
with `integrationTestWebflux`. The OpenTelemetry agent suite runs in two tasks, one per init mode,
72
+
so for `src/integrationTestOtelAgent/` or `src/agentFixture/` run both:
73
73
74
-
3. Run the system test:
75
74
```bash
76
-
.venv/bin/python test/system-test-runner.py test --module<sample-module>
This starts the mock Sentry server, starts the sample app (Spring Boot/Tomcat/CLI), runs tests via `./gradlew :sentry-samples:<sample-module>:systemTest`, and cleans up afterwards.
80
-
81
-
To run **every** system test instead of one module, use the Makefile targets — they also create the
82
-
venv for you:
78
+
Otherwise, with or without a test class filter:
83
79
84
80
```bash
85
-
make systemTest # all system tests (--all)
86
-
make systemTestInteractive # pick the setups to run (--interactive)
Copy file name to clipboardExpand all lines: .cursor/rules/api.mdc
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,9 @@ description: Public API surface, binary compatibility, and common classes to mod
6
6
7
7
## API Compatibility
8
8
9
-
Public API is tracked via `.api` files generated by the [Binary Compatibility Validator](https://github.com/Kotlin/binary-compatibility-validator) Gradle plugin. Each module has its own file at `<module>/api/<module>.api`.
9
+
Public API is tracked via `.api` files generated by the [ABI validation](https://kotlinlang.org/docs/gradle-binary-compatibility-validation.html) built into the Kotlin Gradle plugin. Each module has its own file at `<module>/api/<module>.api`.
10
10
11
-
- **Never edit `.api` files manually.** Run `./gradlew apiDump` to regenerate them.
11
+
- **Never edit `.api` files manually.** Run `./gradlew updateKotlinAbi` to regenerate them.
12
12
- `./gradlew check` validates current code against `.api` files and fails on unintended changes.
13
13
- `@ApiStatus.Internal` marks classes/methods as internal — they still appear in `.api` files but are not part of the public contract.
14
14
- `@ApiStatus.Experimental` marks API that may change in future versions.
Copy file name to clipboardExpand all lines: .cursor/rules/e2e_tests.mdc
+79-14Lines changed: 79 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -3,26 +3,91 @@ alwaysApply: false
3
3
description: Java SDK End to End Tests
4
4
---
5
5
6
-
# Java SDK End to End Tests (System Tests)
6
+
# Java SDK End to End Tests
7
7
8
-
The samples in the `sentry-samples` directory are used to run end to end tests against them.
8
+
End-to-end tests live in the module whose code they test, not in `sentry-samples`. Samples have no
9
+
tests. A test runs the code the way an app would and asserts what reaches Sentry over the real HTTP
10
+
transport.
9
11
10
-
There is a python script (`system-test-runner.py`) that can be used to run one (using `--module SAMPLE_NAME`) or all (using `--all`) system tests.
12
+
## MockSentryServer
11
13
12
-
The script has an interactive mode (`-i`) which allows selection of test setups to execute, whether to run the tests or just prepare infrastructure for testing from IDE.
14
+
`MockSentryServer` (`sentry-test-support`) is an in-process HTTP server on a free port. Point the
15
+
SDK at `server.dsn`, then:
13
16
14
-
The tests run a mock Sentry server via `system-test-sentry-server.py`. Any system under test will then have a DSN set that reflects this local mock server like `http://502f25099c204a2fbf4cb16edc5975d1@localhost:8000/0`.
15
-
By using this local DSN, the system under test sends events to the local mock server.
16
-
The tests can then use `TestHelper` to assert envelopes that were received by the mock server.
17
-
`TestHelper` uses HTTP requests to retrieve the JSON payload of the received events and deserialize them back to objects for easier assertion.
18
-
Tests can then assert events, transactions, logs etc. similar to how they would appear in `beforeSend` and similar callbacks.
17
+
- `awaitEnvelope(timeoutMillis) { predicate }` polls for a matching envelope and fails with what it
18
+
received on timeout.
19
+
- `assertNoEnvelope(millis) { predicate }` checks that nothing matching arrives.
20
+
- `MockSentryServer { ... }` takes a hook that runs before each check while waiting, for example to
21
+
flush an OpenTelemetry tracer provider.
19
22
20
-
`TestHelper` has a lot of helper methods for asserting, e.g. by span name, log body etc.
23
+
`EnvelopeMatchers.kt` has the accessors and matchers: `event()`, `transaction()`, `logs()`,
24
+
`metrics()`, `profileChunk()`, `hasSpanWithOp`, `hasFlag`, `hasLogWithAttribute`, `hasMetric` and
25
+
so on.
21
26
22
-
The end to end tests either expect the system under test to either be running on a server or call `java -jar` to execute a CLI system under test.
27
+
Call `Sentry.flush()` before awaiting when Sentry runs in the test's JVM: logs and metrics are
28
+
batched. Envelopes that arrive late can outlive a server's `reset()`, so tests that share a server
29
+
match on values only they produce.
23
30
24
-
For Spring Boot, we spin up the Spring Boot server. The tests then send requests to that server and assert what is sent to Sentry.
31
+
## Where the tests are
25
32
26
-
End to end tests are also executed on CI using a matrix build, as defined in `.github/workflows/system-tests-backend.yml`.
33
+
- **Core and plain integrations** use their module's `src/test`. Examples: `SentryEndToEndTest`
34
+
(`sentry`), `SentryAppenderIntegrationTest` (`sentry-logback`, `sentry-log4j2`, loading the
35
+
appender from XML), `SentryHandlerIntegrationTest` (`sentry-jul`),
Copy file name to clipboardExpand all lines: .cursor/rules/new_module.mdc
+23-25Lines changed: 23 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,19 @@ alwaysApply: false
8
8
9
9
This document outlines the complete process for adding a new module to the sentry-java repository. Follow these steps in order to ensure proper integration and release management.
10
10
11
+
## Publishing Gate
12
+
13
+
Nothing below is enforced by the build, so a module can look finished, pass CI, and still break
14
+
the release that first ships it. All of the following have to be merged **before** that release:
15
+
16
+
- The module is in the include list in `settings.gradle.kts` (step 1.2)
17
+
- Android (AAR) modules are in `Config.BuildScript.androidLibs` (step 1.4)
18
+
- The module has a row in the packages table in the main `README.md` (step 3)
19
+
- The module is in the integrations dropdown of the matching issue template (step 4)
20
+
- The docs page exists on docs.sentry.io (step 5), because `.craft.yml` has to point at a live URL
21
+
- The module has a full entry in the `registry` target of `.craft.yml` (step 6) — **this one
22
+
fails the release itself**, not just the module
23
+
11
24
## Step-by-Step Process
12
25
13
26
### 1. Create the Module Structure
@@ -39,10 +52,12 @@ val SENTRY_FOO_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.foo"
39
52
The module's `build.gradle.kts` consumes it in both `buildConfig` and the jar manifest
40
53
(`Sentry-SDK-Name` / `Sentry-SDK-Package-Name`) — see `sentry-kafka/build.gradle.kts`.
41
54
42
-
4. Add the instrumented library to `gradle/libs.versions.toml` and depend on it with
55
+
4. For an Android module, add the artifact id to `androidLibs` in `buildSrc/src/main/java/Config.kt`.
56
+
57
+
5. Add the instrumented library to `gradle/libs.versions.toml` and depend on it with
43
58
`compileOnly(libs.<lib>)`, so the integration does not force the dependency on users.
44
59
45
-
5. Register the integration with the SDK so it is reported in the `sdk` payload. Every
60
+
6. Register the integration with the SDK so it is reported in the `sdk` payload. Every
46
61
integration does this — see `sentry-openfeature/.../SentryOpenFeatureHook.java`:
47
62
48
63
```java
@@ -54,24 +69,16 @@ static {
54
69
addIntegrationToSdkVersion("{IntegrationName}");
55
70
```
56
71
57
-
6. If adding a JVM sample, add E2E (system) tests, following the structure we have in the existing JVM examples.
58
-
The test should then be added to `test/system-test-runner.py` and `.github/workflows/system-tests-backend.yml`.
72
+
7. Samples have no tests. Add end-to-end coverage of what the sample shows to the module it uses,
73
+
against `MockSentryServer`, as described in the `e2e_tests` rule.
59
74
60
75
`sentry-bom` and the root `build.gradle.kts` need no change — they iterate over subprojects.
61
76
62
77
### 2. Create Module Documentation
63
78
64
-
Create a `README.md` in the module directory with the following structure:
65
-
66
-
```markdown
67
-
# sentry-{module-name}
79
+
Create a `README.md` in the module directory: the module name as the heading, what it instruments, and a high level overview.
68
80
69
-
This module provides an integration for [Technology/Framework Name].
70
-
71
-
Please consult the documentation on how to install and use this integration in the Sentry Docs for [Android](https://docs.sentry.io/platforms/android/integrations/{module-name}/) or [Java](https://docs.sentry.io/platforms/java/tracing/instrumentation/{module-name}/).
72
-
```
73
-
74
-
The following tasks are required only when adding a module that isn't a sample.
81
+
Steps 3 to 6 are required only when adding a module that isn't a sample.
75
82
76
83
### 3. Update Main README.md
77
84
@@ -97,18 +104,9 @@ Add the necessary documentation to [docs.sentry.io](https://docs.sentry.io):
97
104
- For Android modules: Add to Android platform docs, usually in integrations section
98
105
- Include installation instructions, configuration options, and usage examples
99
106
100
-
### 6. Post release tasks
101
-
102
-
Remind the user to perform the following tasks after the module is merged and released:
103
-
104
-
1. Add the SDK to the Sentry release registry, following the instructions in the [sentry-release-registry README](https://github.com/getsentry/sentry-release-registry#adding-new-sdks)
107
+
### 6. Add the Module to `.craft.yml`
105
108
106
-
2. Add the module to `.craft.yml` in the `sdks` section:
107
-
```yaml
108
-
sdks:
109
-
# ... existing modules ...
110
-
maven:io.sentry:sentry-{module-name}:
111
-
```
109
+
Add the module to the `registry` target in `.craft.yml`, including all metadata fields.
0 commit comments