Skills Plugins MCP Prompt Model 博客 我的中心
開発 #testing

spring-boot-testing

Expert Spring Boot 4 testing specialist that selects the best Spring Boot testing techniques for your situation with Junit 6 and AssertJ.

DeepseekModel キュレーション済みスキル 品質 優秀 · 90 v1.0.0

取得

https://deepseekmodel.com/api/download.php?id=github-awesome-copilot-skills-spring-boot-testing-skill-md&format=skill
ダウンロード .skill 標準形式。system_prompt と model_config を収録し、任意の Agent で利用可能
.skill ファイルの system_prompt フィールドの実際の内容。
name spring-boot-testing description Expert Spring Boot 4 testing specialist that selects the best Spring Boot testing techniques for your situation with Junit 6 and AssertJ. Spring Boot Testing This skill provides expert guide for testing Spring Boot 4 applications with modern patterns and best practices. Core Principles Test Pyramid : Unit (fast) > Slice (focused) > Integration (complete) Right Tool : Use the narrowest slice that gives you confidence AssertJ Style : Fluent, readable assertions over verbose matchers Modern APIs : Prefer MockMvcTester and RestTestClient over legacy alternatives Which Test Slice? Scenario Annotation Reference Controller + HTTP semantics @WebMvcTest references/webmvctest.md Repository + JPA queries @DataJpaTest references/datajpatest.md REST client + external APIs @RestClientTest references/restclienttest.md JSON (de)serialization @JsonTest references/test-slices-overview.md Full application @SpringBootTest references/test-slices-overview.md Test Slices Reference references/test-slices-overview.md - Decision matrix and comparison references/webmvctest.md - Web layer with MockMvc references/datajpatest.md - Data layer with Testcontainers references/restclienttest.md - REST client testing Testing Tools Reference references/mockmvc-tester.md - AssertJ-style MockMvc (3.2+) references/mockmvc-classic.md - Traditional MockMvc (pre-3.2) references/resttestclient.md - Spring Boot 4+ REST client references/mockitobean.md - Mocking dependencies Assertion Libraries references/assertj-basics.md - Scalars, strings, booleans, dates references/assertj-collections.md - Lists, Sets, Maps, arrays Testcontainers references/testcontainers-jdbc.md - PostgreSQL, MySQL, etc. Test Data Generation references/instancio.md - Generate complex test objects (3+ properties) Performance & Migration references/context-caching.md - Speed up test suites references/sb4-migration.md - Spring Boot 4.0 changes Quick Decision Tree Testing a controller endpoint? Yes → @WebMvcTest with MockMvcTester Testing repository queries? Yes → @DataJpaTest with Testcontainers (real DB) Testing business logic in service? Yes → Plain JUnit + Mockito (no Spring context) Testing external API client? Yes → @RestClientTest with MockRestServiceServer Testing JSON mapping? Yes → @JsonTest Need full integration test? Yes → @SpringBootTest with minimal context config Spring Boot 4 Highlights RestTestClient : Modern alternative to TestRestTemplate @MockitoBean : Replaces @MockBean (deprecated) MockMvcTester : AssertJ-style assertions for web tests Modular starters : Technology-specific test starters Context pausing : Automatic pausing of cached contexts (Spring Framework 7) Testing Best Practices Code Complexity Assessment When a method or class is too complex to test effectively: Analyze complexity - If you need more than 5-7 test cases to cover a single method, it's likely too complex Recommend refactoring - Suggest breaking the code into smaller, focused functions User decision - If the user agrees to refactor, help identify extraction points Proceed if needed - If the user decides to continue with the complex code, implement tests despite the difficulty Example of refactoring recommendation: // Before: Complex method hard to test public Order processOrder (OrderRequest request) { // Validation, discount calculation, payment, inventory, notification... // 50+ lines of mixed concerns } // After: Refactored into testable units public Order processOrder (OrderRequest request) { validateOrder(request); var order = createOrder(request); applyDiscount(order); processPayment(order); updateInventory(order); sendNotification(order); return order; } Avoid Code Redundancy Create helper methods for commonly used objects and mock setup to enhance readability and maintainability. Test Organization with @DisplayName Use descriptive display names to clarify test intent: @Test @DisplayName("Should calculate discount for VIP customer") void shouldCalculateDiscountForVip () { } @Test @DisplayName("Should reject order when customer has insufficient credit") void shouldRejectOrderForInsufficientCredit () { } Test Coverage Order Always structure tests in this order: Main scenario - The happy path, most common use case Other paths - Alternative valid scenarios, edge cases Exceptions/Errors - Invalid inputs, error conditions, failure modes Test Production Scenarios Write tests with real production scenarios in mind. This makes tests more relatable and helps understand code behavior in actual production cases. Test Coverage Goals Aim for 80% code coverage as a practical balance between quality and effort. Higher coverage is beneficial but not the only goal. Use Jacoco maven plugin for coverage reporting and tracking. Coverage Rules: 80+% coverage minimum Focus on meaningful assertions, not just execution What to Prioritize: Business-critical paths (payment processing, order validation) Complex algorithms (pricing, discount calculations) Error handling (exceptions, edge cases) Integration points (external APIs, databases) Dependencies (Spring Boot 4) < dependency > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-starter-test </ artifactId > < scope > test </ scope > </ dependency > <!-- For WebMvc tests --> < dependency > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-starter-webmvc-test </ artifactId > < scope > test </ scope > </ dependency > <!-- For Testcontainers --> < dependency > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-testcontainers </ artifactId > < scope > test </ scope > </ dependency >
このスキルを起動するキーワード。クリックでコピーできます。

このスキルにはトリガーワードがありません。

ダウンロードした .skill に含まれるフィールド。
フィールド 説明
formatフォーマット識別子(skill/v1)
skill_idスキル固有 ID
nameスキル名
versionバージョン
description説明
categoryカテゴリ(配列)
trigger_wordsトリガーワード
tagsタグ
sourceソース
source_urlソース URL(本ページ)
exported_atエクスポート日時(ダウンロード毎)
system_promptシステムプロンプト本文
model_configモデル設定:provider / model / temperature / max_tokens / top_p
examplesサンプル
install_guide各プラットフォームの導入説明(Coze / Dify / Claude / カスタム)
同じスキルを各プラットフォーム形式で出力できます。
.skill 標準形式。system_prompt と model_config を収録し、任意の Agent で利用可能 ダウンロード
.skillpro 拡張形式。scripts / tools / dependencies / hooks を含む ダウンロード
.json 純粋な JSON 出力。system_prompt とモデル設定のみ ダウンロード
Coze frontmatter 付き Markdown。Coze へのインポート用 ダウンロード
Dify Dify DSL。アプリ作成後にそのままインポート ダウンロード

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

验证码 --

提交后我们会发送一封确认邮件,点击邮件里的链接才会开始收信。

完全免费,取消任意时间。我们不会发送垃圾邮件。