I'm working on a backend service that interacts heavily with other services. It has a frightening lack of unit tests, so I really want to write some tests to ease future developement.
The problem is, there are a lot of RPC calls and database operations. For example, to complete operation A, you first make an RPC call to service B, then get data from database C, finally you write data to database D and return the response. As a back-end service, it is a combination of many such operations. It appears unclear to me how to correcly write tests for these opeartions.
My first guess is to resturcture the code or use mock testing or both. From my point of view, restructuring the whole codebase would be a huge task that I dare not do. Mock testing would be a little troublesome since there are so many services/databases involved and the involved data is complicated. I'm not quite sure how to do this the right way.
I would appreciate if someone could at least give me directions on this matter. How should I write unit tests for the code? Or do there exist better practices for this scenario?
Aucun commentaire:
Enregistrer un commentaire