I have Foo foo = Mockito.mock(Foo.class); in my test, and my classes are essentially as below:
class Foo extends AbstractFoo {
// ...
}
abstract class AbstractFoo {
// ...
public Object someVar;
void baz() {
someVar.thing(); // this throws the exception
}
}
The issue is that when foo's baz() method is called it throws NullPointerExceptions because someVar hasn't been initialized. The baz() method is void so it can't be stubbed and it's also not overridden in the Foo class.
Is there a way to "stub" the baz() method, skip it, or otherwise get around the NullPointerExceptions it is throwing without setting someVar?
Aucun commentaire:
Enregistrer un commentaire