I'm working to a project consisting in abstracting the data layer for a legacy system, putting all the diverse datasources behind a Web Service that must provide basic CRUD functionalities. We are using JPA so we have a Repository per table, but there are really a ridiculous amount of tables and even to create a simple business entity we have to interact with many tables, not only for creating new rows, but also editing other rows from other table or deleting other entries. This means that the Service responsible to create such abstract entity will have around ten dependencies, between repositories and factories, and all of them are used in all the APIs.
Since I'm writing the tests for this service I ended up mocking all these dependencies and setting up their behaviour to the point where there are 50 lines of code only to set up those mocks and since there are many business entities and scenarios, I cannot really reuse the setup for one test.
How can I make those tests more focused, readable and short?
Aucun commentaire:
Enregistrer un commentaire