JUnit, Mockito
Are written for single software parts. Typically one unit test in Java verifies one class method.
- Mockito
- JMockit
- EasyMock
Is a good practice annotate for any attribute if it is a @InjectMocks, @Mock, @Spy or @Captor
@Autowired provides control over where and how binding between beans should be performed. Can be used to in setter methods, in the constructor, in a property or methods with arbitrary names and/or multiple arguments.
@MockBean to replace beans with mocked beans.
@Test to determine that the next method is a test
@SpringBootTest to determine that this class is a Class test of SpringBoot, the test with this annotation will take much longer to execute then a simple unit test. Is used to integration tests.
@SpyBean to create a spy bean instante
Mockito 4 Basics:
- Default Return Values
- Returning Custom Values
- Multiple thenReturn calls
- Throwing Exceptions
- Mocking Void methods
- Argument Matchers
- Verifying Behavior
- Spies
Advanced mockito:
- Argument Captors
- Mockito BDD
- Mocking Static Methods
- Mockito answers
- Mocking Final
Have tests in controller