K8s mock service

2/24/2018

I have a K8s service A that is dependent(calling it's APIs) on service B. I want to write a component test for service A only, how can I mock service B? which mean mock it's responses.

-- kobikis
kubernetes
mocking
testing

1 Answer

3/28/2018

Your question is a bit unspecific which is probably why you got downvoted. Let me try to answer reasonably anyway. For me that sounds like a general question about software testing and not really something about Kubernetes itself. IMO it is not really useful to mock network dependencies. This is because you hard code assumptions of API integrity and thus create a safe harbour of your tests which are designed to never fail. When you want to test APIs of such dependencies you want to have integration tests or full stack tests or whatever. When writing unit tests for your software project you should concentrate on algorithmic in memory business logic.

-- xh3b4sd
Source: StackOverflow