Where does that exception come from?

In a generated test i found a mocked method, which should throw an IllegalStateException (red line). The method getAbholerNr() is a simple getter for a field - it does not throw any exception by itself, there is no interface in between declaring a thrown exception.
The call loadAllKontingente() (blue line) throws the IllegalStateException only because of the synthetic mocked exception in getAbholer() .thenThrow().

The question is: why and how does Diffblue create this exception on an innocent mocked method (getAbholerNr())?
These show up (rarely) in other tests with other methods in other classes - but i’d say, most of them are simple getters too, without any chance to throw any exception.
This superfluous test is not a big problem - but maybe Diffblue wanted to tell us something different?

Hi @dvholten

This is a good observation - I have spoken internally and found that in these cases Cover will look for any exceptions referenced by the class under test to throw, if it can’t find anything else to mock.
Is there a IllegalStateException somewhere in the AbholerBean class?
If so, you could try setting a custom rule to supply the AbholerNr with a reasonable value.

Let me know how this goes, or if you have any further questions

Best regards,
Jane @ Diffblue