Replacing Troublesome Behavior with Stubs
Learn the implementation and use cases of stubs.
Let’s focus first on verifying how we populate an Address
using the JSON response from the Http
call. To do that, we’d like to change the behavior of HttpImpl
’s get()
method for purposes of the test so that it returns a hardcoded JSON string.
stub
An implementation that returns a hard-coded value for the purposes of testing is known as a stub.
The HttpImpl
implements the functional Http
interface. Let’s create a stub ...
Access this course and 1400+ top-rated courses and projects.