I need to fix the code of an old employee who no longer works for my company. I've already made changes and unit tests that worked well. My problem lies with the integration tests.
I need to create an integration test for my code, but it has to be a simulated test, because I am not able to make real requests to the API.
For the integrated tests I cannot use mock to simulate the values of the API, and it would be necessary to create a simulated server to perform the integrated tests while I cannot access the API. I am only allowed to access the API and test with it after all the mock tests are working.
So, how can I create a simulated integration test, without requesting the API?
I need to fix the code of an old employee who no longer works for my company. I've already made changes and unit tests that worked well. My problem lies with the integration tests.
I need to create an integration test for my code, but it has to be a simulated test, because I am not able to make real requests to the API.
For the integrated tests I cannot use mock to simulate the values of the API, and it would be necessary to create a simulated server to perform the integrated tests while I cannot access the API. I am only allowed to access the API and test with it after all the mock tests are working.
So, how can I create a simulated integration test, without requesting the API?
Share Improve this question edited Feb 10 at 17:41 Starship 8032 gold badges14 silver badges26 bronze badges asked Feb 10 at 17:33 Mr.JMr.J 11 bronze badge 3- Use Flask or Fastapi to create a test version of the api you need to connect to. You then emulate all the required enpoints to return the expected resonse. – MortenB Commented Feb 10 at 20:07
- 1 I'll try with flask, create a server that simulates the API, I hope it works. Do you recommend I try it on Flask or FastAPI? My big problem is that at the moment I can't make real requests to the API I'm using, which complicates my integrated tests, making me have to resort to an API simulation. I'm sorry if I get confused, I'm new to this language. – Mr.J Commented Feb 11 at 11:08
- I recommend fastapi because you have openapi out of the box, it is also well documented if you need to emulate logon like oauth2: fastapi.tiangolo/tutorial/security/simple-oauth2 – MortenB Commented Feb 11 at 13:57
1 Answer
Reset to default 0If you know the api documentation like swagger or postman collection. I guess, that should help. That would help you know what is needed and what is to be expected vice versa. If you still expect it is an integration issue, let the backend operations know and raise an issue . Not sure about your absolute scenario, but i gave a basic problem solving approach.