I want to write an API test, kind of end-to-end test, for my application.
Assume that I want to get all Foo
s in the system. When I hit an endpoint /foo/all
, I fetch data using HTTPClient
and get some dependent objects of Foo
from another microservice Bar
.
My unit tests are ok. I can also boot my api for tests , however I don't want to call Bar
service as I don't want its dependency on my tests, instead, I want to make something like a stub.
So how can I mock those services? I cannot mock HttpClient
and override ConfigureServices
method in my test application bootstrap process, because HttpClient
does not implement any interface.
Thanks.