मुख्य सामग्री पर जाएँ
Skillpedia
टेस्टिंग40k · #7431

spring-boot-testing

यह क्या करती है

यह टूल आपको Spring Boot code की टेस्टिंग में मदद करता है। आप क्या जांचना चाहते हैं, इसके आधार पर यह सबसे अच्छा testing तरीका चुनता है। यह आधुनिक tools का इस्तेमाल करता है, ताकि टेस्ट लिखना आसान और साफ हो।

कब इस्तेमाल करें

  • ✓जब आप जांचना चाहते हों कि कोई website 'endpoint' (communication port) सही काम कर रहा है या नहीं।
  • ✓जब आप देखना चाहते हों कि आपके program का वह हिस्सा जो डेटा सेव और पढ़ता है, सही है या नहीं।
  • ✓जब आपको जांचना हो कि आपका program internet पर दूसरी services से कैसे बात करता है।

Skill का लिंक

https://github.com/github/awesome-copilot/blob/main/skills/spring-boot-testing/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/github/awesome-copilot/blob/main/skills/spring-boot-testing/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मैं कैसे टेस्ट करूं कि मेरा code जो डेटा database में सेव करता है, सही काम कर रहा है?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह टूल जो आप टेस्ट करना चाहते हैं उसका विश्लेषण करता है और सबसे अच्छा तरीका सुझाता है, जैसे visual हिस्से के लिए `@WebMvcTest` या डेटा हिस्से के लिए `@DataJpaTest`। यह साफ-सुथरे टेस्ट लिखने के लिए AssertJ जैसी libraries के इस्तेमाल की भी सलाह देता है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Spring Boot Testing

This skill provides expert guide for testing Spring Boot 4 applications with modern patterns and best practices.

Core Principles

  1. Test Pyramid: Unit (fast) > Slice (focused) > Integration (complete)
  2. Right Tool: Use the narrowest slice that gives you confidence
  3. AssertJ Style: Fluent, readable assertions over verbose matchers
  4. 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

Testing Tools Reference

Assertion Libraries

Testcontainers

Test Data Generation

Performance & Migration

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:

  1. Analyze complexity - If you need more than 5-7 test cases to cover a single method, it's likely too complex
  2. Recommend refactoring - Suggest breaking the code into smaller, focused functions
  3. User decision - If the user agrees to refactor, help identify extraction points
  4. 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

…

अक्सर पूछे जाने वाले सवाल

'Test Pyramid' क्या है?

यह टेस्ट व्यवस्थित करने का एक तरीका है: बहुत सारे छोटे और तेज़ टेस्ट (unit), कुछ मध्यम टेस्ट (slice), और कुछ बड़े, धीमे टेस्ट (integration)।

AssertJ क्यों इस्तेमाल करें?

AssertJ टेस्ट को पढ़ने और लिखने में आसान बनाता है, क्योंकि यह जांचने के लिए आसान भाषा जैसा तरीका देता है कि नतीजे सही हैं या नहीं।

'Test Slices' क्या हैं?

ये आपके application के खास हिस्सों पर केंद्रित टेस्ट होते हैं, जैसे सिर्फ network layer या सिर्फ data layer। इससे टेस्ट तेज़ और ज़्यादा सटीक होते हैं।

जानकारी

लेखक का मूल विवरण

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

repo: github/awesome-copilot

लोकप्रियता

GitHub स्टार
40k
रैंकिंग में स्थान
#7431
लाइसेंस
MIT
अपडेट की गई
15/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

acquire-codebase-knowledge

40k

आपके एजेंट को किसी मौजूदा code प्रोजेक्ट को समझने और उसका documentation बनाने में मदद करता है। यह नए लोगों को प्रोजेक्ट से जोड़ने या architecture का सार जानने में उपयोगी है।

लेखन और डॉक्यूमेंटडॉक्यूमेंटेशन

acreadiness-assess

40k

आपके एजेंट को किसी प्रोजेक्ट की AI के लिए तैयारी जाँचने और रिपोर्ट बनाने देता है। यह समझने में उपयोगी है कि प्रोजेक्ट AI tools इस्तेमाल करने के लिए कितना तैयार है।

लेखन और डॉक्यूमेंटडॉक्यूमेंटेशन

acreadiness-generate-instructions

40k

आपके एजेंट को assessment के आधार पर AI tools के लिए निर्देश बनाने में मदद करता है। यह बताता है कि AI कोड के साथ बेहतर कैसे काम करे और पहचानी गई कमियाँ कैसे दूर हों।

लेखन और डॉक्यूमेंटडॉक्यूमेंटेशन

acreadiness-policy

40k

आपके एजेंट को AI प्रोजेक्ट assessment के लिए नीतियाँ तय करने या लागू करने में मदद करता है। यह प्रोजेक्ट्स के मूल्यांकन को मानक बनाने और compliance सुनिश्चित करने में उपयोगी है।

AI और एजेंटएजेंट

मिलती-जुलती skills