Answer the question
In order to leave comments, you need to log in
How to test top-level business logic?
Let me formulate the question with a specific example.
Suppose that in order for the controller (MVC is just an example, the question is not related to any specific technology) to return the necessary data, you need to do the following:
1. Retrieve the data from the storage.
2. Filter them out.
3. Sort.
4. Select a page to display (pagination).
Each of these four elementary actions is very easy to cover with unit tests.
But still, somewhere there must be code that will call these methods sequentially and generate data for transmission to the Presentation Layer.
Question: where should this code be located?
1. If in the controller, we get the ease of testing business logic, but at the same time a Fat Stupid Ugly Controller (because it has business logic).
2. If we create such a method in the business logic layer, then it will be public, and elementary methods will be private. And because we have to test only public methods (class API), then we need to write tests for this overarching method, which is hell.
Where should this code be (in the context of unit testing)?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question