I'm beginner in Spring boot till now I have complete the REST Operations(GET,POST,PUT,DELETE) with MYSQL as a database and I want to write the unit test cases for Controller class and Service class I use Mockito framework for writing test cases and I don't know when I use.
I'm stuck with
- where I use
@SpringBootTestand@ExtendsWith(MockitoExtension.class)? @SpringBootTestitself enough?
@SpringBootTest used to integrate test environment, enables you to test controllers, services, other repositories.
if you're writing unit tests for your controller and service classes using Mockito, you'll typically use @ExtendWith(MockitoExtension.class) to enable Mockito and then mock any dependencies of the class you're testing.