Detailed and basic usage of Mockito
Mockito is a Mock framework for Java single-testing, but it can also be used with other single-testing frameworks in addition to JUnit. Mockito changes the behavior of a class or object, allowing us to focus more on testing the code logic without the effort of constructing the data. The basic concept Mocks can be of two types, Class and Partial,so Mockito is called spy. The behavior of changing methods on mock objects is called Stub. A Mock process is called a Mock Session, and it records all the Stubbing. It consists of three steps: +----------+ +------+ +--------+ | Mock/Spy | ===> | Stub | ===> | Verify | +----------+ +------+ +--------+ Class Mock A Class Mock changes the behavior of a Class so that the object it mocks completely loses its original behavior. Method returns default values (null, false, 0, etc.) if it is not pegged. The most basic usage is as follows: 1 2 3 4 5 6 7 8 9 10 11 12 import static org.mockito.Mockito.*; // use List.class to cre