I have developed a REST service. The service have one Api endpoint: v1/customer. This Api does two things:
- It executes the business logic in main thread
- Spawns a child thread to perform the non critical DB writes. The main thread returns response to client immediately, whereas the child thread write to DB asynchronously.
As both of the these operations Step 1 and 2 are not synchronous, it is becoming increasingly challenging to test both of these scenario. Let's say when I try to test the API. I am testing two things (api response and DB writes) As the DB writes happen async fashion. I have to use a Thread.sleep(2000). This process is not scalable and doesn't yield right result. Soon I might have 1000 test cases to run and the total time to run all these testcases will increase enormously. What design technique shall I use to test the DB writes keeping performance and execution time in mind.
Aucun commentaire:
Enregistrer un commentaire