← Back to list

java-testing
by bitsoex
Bitso Java API Wrapper
⭐ 34🍴 30📅 Jan 24, 2026
SKILL.md
name: java-testing description: > Java testing guidelines using Spock Framework and Groovy. Covers test structure, mocking patterns, persistence testing with Testcontainers, gRPC testing, and Spring Boot test configurations. Use when writing or reviewing tests. compatibility: Java projects using Spock Framework metadata: version: "1.0.0" technology: java category: testing tags: - java - testing - spock - groovy - testcontainers
Java Testing
Guidelines for writing tests in Java projects using the Spock Framework and Groovy.
When to use this skill
- Writing new tests
- Reviewing test code
- Setting up test infrastructure
- Configuring Testcontainers
- Mocking dependencies in Spring Boot tests
Skill Contents
Sections
- When to use this skill (L24-L31)
- Quick Start (L57-L77)
- Key Patterns (L78-L87)
- Mocking Patterns (L88-L123)
- Persistence Testing (L124-L139)
- References (L140-L147)
- Related Rules (L148-L152)
- Related Skills (L153-L158)
Available Resources
📚 references/ - Detailed documentation
- grpc testing
- junit5 migration
- spock patterns
- test setup workflow
- test utilities
- testcontainers setup
Quick Start
1. Test Structure
def "should do Y when X"() {
given:
// create test data
when:
// execute process
then:
// assert output
where: // use test table if suited
}
2. Test Naming
- Test files:
<ClassName>Spec.groovy - Test methods:
"should [expected behavior] when [condition]"
Key Patterns
| Pattern | When to Use |
|---|---|
| Spock Mock | Unit tests without Spring context |
| @SpringBean | Spring integration tests with mocks |
| @ServiceConnection | Testcontainers database connection |
| InProcessServer | gRPC client/server testing |
| Data Tables | Multiple test cases with same structure |
Mocking Patterns
Unit Tests (No Spring)
class SomeSpec extends Specification {
SomeInterface someInterface = Mock()
def "test method"() {
given:
def underTest = new ClassUnderTest(someInterface)
when:
// call method
then:
1 * someInterface.someMethod("value") >> responseClass
}
}
Spring Integration Tests
@SpringBootTest
class SomeSpec extends Specification {
@SpringBean
SomeInterface someInterface = Mock()
def "test method"() {
when:
// call method
then:
1 * someInterface.someMethod(_) >> { throw new RuntimeException() }
}
}
Persistence Testing
Use Testcontainers with @ServiceConnection for database tests:
@Configuration
class IntegrationTestConfiguration {
@Bean
@ServiceConnection
PostgreSQLContainer<?> postgreSQLContainer() {
return new PostgreSQLContainer<>("postgres:14-alpine")
.withDatabaseName("test_db")
}
}
References
| Reference | Description |
|---|---|
| references/spock-patterns.md | Advanced Spock patterns |
| references/testcontainers-setup.md | Testcontainers configuration |
| references/grpc-testing.md | gRPC test patterns |
Related Rules
.cursor/rules/java-testing-guidelines.mdc- Full testing reference.cursor/rules/java-flyway-migrations.mdc- Flyway for test schema
Related Skills
| Skill | Purpose |
|---|---|
| java-coverage | JaCoCo test coverage |
| gradle-standards | Test dependency bundles |
Score
Total Score
65/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
✓フォーク
10回以上フォークされている
+5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon