StableMock Examples Library
Browse a comprehensive collection of copy-paste ready examples for StableMock. From strict REST mocking to complex GraphQL and SOAP scenarios.
Don't reinvent the wheel. Browse our curated collection of integration testing patterns. Every example is production-ready and fully tested in our CI pipeline.
Getting Started
Basic Spring Boot Test
The 'Hello World' of integration testing. Mocks a simple JSON GET request using RestTemplate.
Pure JUnit 5 (No Spring)
Lightweight mocking without the Spring Context overhead. Uses parameter injection for the port.
Advanced Protocols
GraphQL Mocking
Matches GraphQL queries by body content. handles variables and specific operation names.
XML & SOAP Services
Auto-detects SOAP envelopes and generates namespace-agnostic XPath matchers.
Complex Scenarios
Dynamic Field Handling
Automatically detects and ignores changing fields like Timestamps, UUIDs, and Random Tokens.
Multi-Service Orchestration
Mocks multiple distinct upstream APIs (User Service + Audit Service) in a single test.
Stateful Pagination
Simulates state with 'scenario=true'. Returns Page 1, then Page 2 for sequential calls.
Want to contribute an example?
We love seeing how developers use StableMock in the wild. Submit a PR to our examples repo.
Submit on GitHub