A library for mocking HTTP responses in Android instrumentation tests using Hamcrest matchers.
RESTMock is an HTTP server library for Android instrumentation tests that mocks REST API responses. It builds on Square's okhttp/MockWebServer and allows developers to specify request matchers and define corresponding mock responses, enabling isolated and repeatable network testing without relying on real backend services.
Android developers writing instrumentation tests who need to mock network calls for reliable and deterministic testing of app features that depend on API responses.
Developers choose RESTMock for its simple, expressive API using Hamcrest matchers, seamless integration with Android testing frameworks, and features like response chaining, delays, and request verification that make complex testing scenarios straightforward.
HTTP Server for Android Instrumentation tests
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enables precise and flexible request matching using Hamcrest, allowing developers to define complex criteria like pathContains or custom matchers for accurate API simulation.
Supports chaining multiple responses for a single endpoint and simulating network delays with methods like delayBody(), ideal for testing sequential calls or network conditions.
Provides verification tools to check invocation counts and patterns with RequestsVerifier, ensuring that API interactions are correctly triggered during tests.
Configurable for HTTPS with default or custom SSL certificates, facilitating secure connection testing in instrumentation environments as detailed in the HTTPS section.
Designed specifically for Android instrumentation tests, making it unsuitable for unit tests, other platforms, or non-instrumentation scenarios without modification.
Requires configuring test runners, managing assets for file responses, and integrating with the app's network client, which can be complex for new users as shown in the setup steps.
Built on okhttp/MockWebServer, so updates or issues in these dependencies may impact stability and require maintenance.
Mocks are defined programmatically in Java/Kotlin code, which might be less appealing for teams wanting declarative or visual mocking approaches.