While the basic aim of unit testing is to find defects, approaches for writing unit tests for each of the layers are different. In this section, we will take a quick look at unit testing examples and best practices for different layers.
Unit testing
The business layer
When writing tests for the business layer, we recommend that you avoid using Spring Framework in the unit tests. This will ensure that your tests are framework independent and will run faster.
The following is an example of a unit test written without using Spring Framework:
@RunWith(MockitoJUnitRunner.class)
public class BusinessServiceMockitoTest {
private static final User DUMMY_USER = new User("dummy");
@Mock
private DataService...