Unable to generate test inputs not throwing a trivial exception

Hello!

I’m doing some tests with diffblue tool, but appears this message.

Unable to generate test inputs not throwing a trivial exception.

What do i need to fix, to have a unit test generation of this? Thank you in advance!

Here is a sample of code.

@Override
@Transactional
public void validarTieneReglaNegocio(PerfilAccesoDetalle pad) {
Acceso acceso = accesoService
.consultarPorId(pad.getAcceso().getIdAcceso());
if (acceso.getReglaNegocio() != null) {
throw new RelacionInvalidaException(ACCESO_TIENE_REGLA_NEGOCIO);
}
}

Hi Hernan!

My guess is that acceso or pad.getAcceso() end up being always null, for some reason. It might be that Diffblue is unable to find the right constructors and setters to populate those. Just for the sake of troubleshooting, what happens if you initialize the acceso field to something non-null (perhaps by modifying the constructor of whatever the enclosing class is)?
You could do the same with the acceso field of PerfilAccesoDetalle.
Hopefully this will help identifying where the plugin falls short.

Hi @hernan10406: I suspect this could be related to the code’s dependency on accesoService; From what I understand if Diffblue cannot find a concrete implementation of any object referenced in the code under test it will bail out from generating the test (I don’t think Diffblue is aware of dependency injection)

Please also see my question which seems related: Diffblue Cover should provide meaningful stubs for object dependencies