This is a really newbie question but I don’t know how to stub this.
I have to mock a method to return Class like this.
public Class<? extends SomeClass> getAClass();
if I do something like this
when(this.someInstance.getAClass())
.thenReturn(SomeClassThatExtendsSomeClass.class);
I get compilation error.
The method thenReturn(Class<capture#1-of ? extends SomeClass>) in the type OngoingStubbing<Class<capture#1-of ? extends SomeClass>> is not applicable for the arguments (Class<SomeClassThatExtendsSomeClass>)
If the method declaration can be changed to what @Bohemian suggested above,
then you can write your mock statement as follows:
Otherwise, the doReturn semantics should be used as follows: