@ExtendWith(MockitoExtension.class) instead of @ExtendWith(SpringExtension.class)

Hello dear people,

I have a question about diffblue cover with spring boot framework. When I want to generate unit tests for my service layer (annotated with @Service) with Diffblue Cover, it detects the framework behind it, and notices it is about Spring, then it uses spring test context to write tests. Is there any way by forcing Diffblue Cover to use only JUNIT5+Mockito (Somehow in the settings in IntelliJ). Specifically:

@ExtendWith(MockitoExtension.class)
class XServiceTest {
    @Mock    private XRepository xRepository;    
    @Mock    private YRepository yRepository;    

    @InjectMocks
    private XService xService;
    
    .....
    
    @Test
    ....

intead of:

@ContextConfiguration(classes = XService.class})
@ExtendWith(SpringExtension.class)
class XServiceTest {
    @MockBean    private XRepository xRepository;    
    @MockBean    private YRepository yRepository;    

    @Autowired
    private XService xService;
    
    .....
    
    @Test
    ....

At the moment I do that manually.

Thanks for your answers :innocent:

Hi abdessamad_abba,

Thank you for contacting Diffblue Support, and we are happy to see you trying our product. For now Diffblue Cover can only write Spring-based unit tests when the framework is detected. Please let us know if you need more help and we will be happy to offer our support.

Kind Regards.
Cristian

it should not use springboot test for unit test , am i correct , i think this tools needed to fix this

Hi, Please note that when using Spring Boot, Spring Boot Test should be included in your dependencies list as recommended on the diffblue Prerequisites page Prerequisites | Diffblue Docs
Please let us know if you have questions on this issue.

Kind Regards,
Cristian