Generated test is testing mock method instead of original method


I just installed Diffblue and I am trying to use it to create tests on an existing class. I tried to create a test on the save method which should call the corresponding method from the repository class to save the object to the database. Diffblue creates the test, but the test doesn’t call the method that needs to be tested, it calls a mock instead.

Is this expected behavior? My expectation would be for the mock repository’s save method to be defined and for the save method to be called from the service.

Here is the example of generated test:

    void testSave() {
        AccountRoleDTO accountRoleDTO = new AccountRoleDTO();

        AccountRoleAssignedPrivDTO accountRoleAssignedPrivDTO = new AccountRoleAssignedPrivDTO();
        when( any()))

        AccountRoleDTO accountRoleDTO1 = new AccountRoleDTO();

        AccountRoleAssignedPrivDTO accountRoleAssignedPrivDTO1 = new AccountRoleAssignedPrivDTO();
        verify(accountRoleAssignedPrivService).save((AccountRoleAssignedPrivDTO) any());

here is the save method that should be tested:

    public AccountRoleAssignedPrivDTO save(AccountRoleAssignedPrivDTO accountRoleAssignedPrivDTO) {
        log.debug("Request to save AccountRoleAssignedPriv : {}", accountRoleAssignedPrivDTO);
        AccountRoleAssignedPriv accountRoleAssignedPriv = accountRoleAssignedPrivMapper.toEntity(accountRoleAssignedPrivDTO);
        accountRoleAssignedPriv =;
        return accountRoleAssignedPrivMapper.toDto(accountRoleAssignedPriv);

Hi ivrbovcan,

Thnak you for your message. Please let us know if you tried running Diffblue cover with the “Enable integration tests” option enabled.

This should reduce the amount of mocking. Please let us know if your issues is resolved or if you need more help.

Kind regards.