November 2024
Intermediate to advanced
300 pages
7h 12m
English
The challenge for testing is the code in HttpImpl that calls a real endpoint. To fix the problem, your test can supplant HttpImpl’s live call with logic that instead returns mocked-up data. You’ll create an implementation of HttpImpl known as a stub: It will stub out the real code with a simplified version.
|
|
A stub is a test double that supplants real behavior with a method that returns a hardcoded value. |
HTTP is a functional interface: It contains exactly one abstract method declaration (for get). As a result, you can dynamically and concisely declare an implementation of HTTP using a lambda:
Read now
Unlock full access