简体   繁体   中英

Should Spring Cloud Contract tests actually call an external service?

I'm having trouble finding out the answer to this..

I'm exposing an endpoint, JSON data is being sent to it.

Inside my service I'm then mapping this to a POJO, serialising to a JSON request, then firing that on to my service via OpenFeign (internal service within company).

Should I be mocking everything in terms of the response? Or are contract tests meant to test this integration?

Currently I am analysing the actual response from the service I'm calling.

On the producer side, your controller should have all the services mocked. It means that it will not call a database nor another service to get back the response. What you should do is to create a simple controller object and inject fake / mocked services that will return fixed responses. Contract tests are about checking if you can communicate, not about checking if the functionality is working fine.

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