Skip to content

Commit 4c09f52

Browse files
adinauerclaude
andauthored
Add a /test skill to run singular tests or per module tests (#5111)
* Add a /test skill to run singular tests or per module tests * fix(test): Correct Android task detection in test skill Map modules ending in -android to testDebugUnitTest so Android library modules like sentry-launchdarkly-android do not fall back to test. Add AskUserQuestion to allowed-tools so interactive mode can execute the decision prompts described in the skill under restricted tool settings. Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6839cb0 commit 4c09f52

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

.claude/skills/test/SKILL.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
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.
4+
allowed-tools: Bash, Read, Glob, AskUserQuestion
5+
argument-hint: [interactive] <module-name-or-file-path> [test-class-filter]
6+
---
7+
8+
# Run Tests
9+
10+
Run tests for a specific module. Auto-detects whether to run unit tests or system tests.
11+
12+
## Step 0: Check for Interactive Mode
13+
14+
If `$ARGUMENTS` starts with `interactive` (e.g., `/test interactive sentry ScopesTest`), enable interactive mode. Strip the `interactive` keyword from the arguments before proceeding.
15+
16+
In interactive mode, use AskUserQuestion at decision points as described in the steps below.
17+
18+
## Step 1: Parse the Argument
19+
20+
The argument can be either:
21+
- 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 + test filter** (e.g., `sentry ScopesTest`)
24+
25+
Extract the module name and optional test class filter from the argument.
26+
27+
**Interactive mode:** If the test filter is ambiguous (e.g., matches multiple test classes across modules), use AskUserQuestion to let the user pick which test class(es) to run.
28+
29+
## Step 2: Detect Test Type
30+
31+
| Signal | Test Type |
32+
|--------|-----------|
33+
| Path contains `sentry-samples/` | System test |
34+
| Module name starts with `sentry-samples-` | System test |
35+
| Everything else | Unit test |
36+
37+
## Step 3a: Run Unit Tests
38+
39+
Determine the Gradle test task:
40+
41+
| Module Pattern | Test Task |
42+
|---------------|-----------|
43+
| `sentry-android-*` | `testDebugUnitTest` |
44+
| `sentry-compose*` | `testDebugUnitTest` |
45+
| `*-android` | `testDebugUnitTest` |
46+
| Everything else | `test` |
47+
48+
**Interactive mode:** Before running, read the test class file and use AskUserQuestion to ask:
49+
- "Run all tests in this class, or a specific method?" — list the test method names as options.
50+
51+
If the user picks a specific method, use `--tests="*ClassName.methodName"` as the filter.
52+
53+
With a test class filter:
54+
```bash
55+
./gradlew ':<module>:<task>' --tests="*<filter>*" --info
56+
```
57+
58+
Without a filter:
59+
```bash
60+
./gradlew ':<module>:<task>' --info
61+
```
62+
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+
```
71+
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`).
73+
74+
3. Run the system test:
75+
```bash
76+
.venv/bin/python test/system-test-runner.py test --module <sample-module>
77+
```
78+
79+
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+
## Step 4: Report Results
82+
83+
Summarize the test outcome:
84+
- Total tests run, passed, failed, skipped
85+
- For failures: show the failing test name and the assertion/error message

0 commit comments

Comments
 (0)