简体   繁体   中英

K8s mock service

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM