スキル一覧に戻る
bitsoex

java-testing

by bitsoex

Bitso Java API Wrapper

34🍴 30📅 2026年1月24日
GitHubで見るManusで実行

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

Available Resources

📚 references/ - Detailed documentation


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

PatternWhen to Use
Spock MockUnit tests without Spring context
@SpringBeanSpring integration tests with mocks
@ServiceConnectionTestcontainers database connection
InProcessServergRPC client/server testing
Data TablesMultiple 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

ReferenceDescription
references/spock-patterns.mdAdvanced Spock patterns
references/testcontainers-setup.mdTestcontainers configuration
references/grpc-testing.mdgRPC test patterns
  • .cursor/rules/java-testing-guidelines.mdc - Full testing reference
  • .cursor/rules/java-flyway-migrations.mdc - Flyway for test schema
SkillPurpose
java-coverageJaCoCo test coverage
gradle-standardsTest dependency bundles

スコア

総合スコア

65/100

リポジトリの品質指標に基づく評価

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

レビュー

💬

レビュー機能は近日公開予定です