사용 방법
- 설치 명령을 복사하고 자신의 에이전트 환경에 설치하기 전에 소스 패키지를 확인하세요.
- 필요한 도구, 인증 정보, 지원 환경은 원본 문서에서 확인하세요.
- 입력과 원하는 산출물을 설명하고 출처와 결과를 대조하세요.
npx skills add https://github.com/c0x12c/ai-toolkit --skill testing-strategies시작 전 확인
- 설치에는 모델 구독, API 한도, 파일 접근 권한이 포함되지 않습니다.
- 별점 수와 설치 수는 활동 지표이며 독립적인 품질·보안 검증이 아닙니다.
원본 저장소의 제목, 예시, 코드, 표, 링크, 이미지를 유지해 표시합니다.
Testing Strategies — Quick Reference
Seeintegration-test-setup.mdfor @MicronautTest configuration, Retrofit client setup, and connection pool tuning. Seeexamples.mdfor complete code patterns including MockK, test data builders, and assertions.
Integration Tests
Every endpoint needs an integration test. Extend AbstractControllerTest, use Retrofit clients from module-client, and clean up with truncateAllTables() in @AfterEach.
Key rules:
- Always use Retrofit clients — never raw
HttpRequest - Generate real JWT tokens via
accessToken() - Test full HTTP stack end-to-end, no mocking managers
Test Naming
@Test
fun `{action} - {expected outcome}`() = runBlocking { }
// Examples:
fun `getEmployee - returns employee by id`() = runBlocking { }
fun `getEmployee - returns 404 when not found`() = runBlocking { }
fun `createEmployee - fails with 401 when not authenticated`() = runBlocking { }Required Test Coverage Per Endpoint
- Happy path — basic success case
- Not found — 404 for missing resource
- Auth failure — 401 without token
- Soft delete — deleted records not returned
@Test
fun `getById - returns 404 when not found`() = runBlocking {
val token = accessToken(prepareUser())
assertThrows<HttpException> {
runBlocking {
client.getById(authorization = token, id = UUID.randomUUID())
}
}.also {
assertThat(it.code()).isEqualTo(404)
}
}Repository Tests
Extend AbstractRepositoryTest. Every repository needs these tests at minimum:
class DefaultEmployeeRepositoryTest : AbstractRepositoryTest() {
private val repository = DefaultEmployeeRepository(database)
@BeforeEach
fun cleanup() { database.primary.truncateAllTables() }
@Test
fun `insert - happy path`() { }
@Test
fun `byId - returns entity when exists`() { }
@Test
fun `byId - returns null when not exists`() { }
@Test
fun `byId - returns null when soft deleted`() { }
@Test
fun `deleteById - soft deletes entity`() { }
@Test
fun `update - updates selected fields`() { }
}MockK Rules
mockk<T>()for creating mockscoEvery/coVerifyfor suspend functions (notevery/verify)slot<T>()+capture()to verify what arguments were passedrunTest { }fromkotlinx.coroutines.test— NOTrunBlocking.runTesthandles virtual time and catches coroutine issues.- AAA pattern with comments:
// Given,// When,// Then - Use
@Nested+@DisplayNameto group related tests
Seeexamples.mdfor full MockK code examples,@Nestedpatterns, test data builders, and AssertJ assertions.
Gotchas
Connection pool exhaustion: If parallel tests fail with "cannot acquire connection", bump maxPoolSize to 20. See integration-test-setup.md for the config snippet.
MockK + coroutines: Always use coEvery/coVerify for suspend functions. Plain every/verify won't work and gives confusing errors.
Run Tests
./gradlew test # All tests
./gradlew test --tests "com.yourcompany.EmployeeControllerTest" # One class
./gradlew :app:module-repository:test # One module


