Skip to content

Commit 0fa5d7f

Browse files
committed
Add a /test skill to run singular tests or per module tests
1 parent ad8da22 commit 0fa5d7f

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

.claude/skills/test/SKILL.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
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
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+
| Everything else | `test` |
46+
47+
**Interactive mode:** Before running, read the test class file and use AskUserQuestion to ask:
48+
- "Run all tests in this class, or a specific method?" — list the test method names as options.
49+
50+
If the user picks a specific method, use `--tests="*ClassName.methodName"` as the filter.
51+
52+
With a test class filter:
53+
```bash
54+
./gradlew ':<module>:<task>' --tests="*<filter>*" --info
55+
```
56+
57+
Without a filter:
58+
```bash
59+
./gradlew ':<module>:<task>' --info
60+
```
61+
62+
## Step 3b: Run System Tests
63+
64+
System tests require the Python-based test runner which manages a mock Sentry server and sample app lifecycle.
65+
66+
1. Ensure the Python venv exists:
67+
```bash
68+
test -d .venv || make setupPython
69+
```
70+
71+
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`).
72+
73+
3. Run the system test:
74+
```bash
75+
.venv/bin/python test/system-test-runner.py test --module <sample-module>
76+
```
77+
78+
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.
79+
80+
## Step 4: Report Results
81+
82+
Summarize the test outcome:
83+
- Total tests run, passed, failed, skipped
84+
- For failures: show the failing test name and the assertion/error message

0 commit comments

Comments
 (0)