| name | unit-test |
| description | Writes or modifies unit tests following the project testing guide. Before writing tests, reads agentdocs/unitTest.md for patterns and conventions. Use when the user says "write tests", "add unit tests", "cover with tests", "create test class", "fix tests", "update tests". NOT for UI/instrumentation tests. NOT for integration tests.
|
Before writing or modifying unit tests, read the testing guide: agentdocs/unitTest.md
Checklist
Follow these rules when writing tests:
- Read the guide first —
agentdocs/unitTest.md
- Naming — use
`GIVEN <condition> EXPECT <result>` format
- One test = one assertion — split multiple verifications into separate tests
val fields — declare mocks and SUT as val, no lateinit var or @Before
- No
relaxed = true — always stub explicitly
every/coEvery — use co* variants for suspend functions only
runTest — wrap suspend test bodies in runTest { }
- Region grouping — use
// region / // endregion to group related tests
- Run tests after writing — verify everything passes
Commands
./gradlew :sdk:testDebugUnitTest
./gradlew :sdk:testDebugUnitTest --tests "ClassName"
./gradlew :sdk:testDebugUnitTest --tests "ClassName.methodName"
Workflow
- Read
agentdocs/unitTest.md for patterns and examples
- Read the class under test to understand its behavior
- Write tests following the checklist above
- Run the tests to verify they pass