samedi 15 septembre 2018

How to enable strict_stubs

I've found only three ways how to enable STRICT_STUBS in Mockito (See documemantation)

  1. MockitoJunitRunner

  2. MockitoJUnit.rule().strictness(Strictness.STRICT_STUBS)

  3. Mockito.mockitoSession() .initMocks(this) .strictness(Strictness.STRICT_STUBS) .startMocking()

All of them require to declare stubs via annotations (@Mock lateinit var api: MyApi ). But I'm using mockito-kotlin and declare stubs like that:

val api: MyApi = mock()

or like that:

val api:MyApi = mock{
  on { call("expected-param") } doReturn something
}

Under the hood it uses Mockit.mock method.

Question 1: how can I enable STRICT_STUBS when I use Mockit.mock ?

Question 2: Perhaps it's possible to enable STRICT_STUBS for everything regardless how mock is defined?

Aucun commentaire:

Enregistrer un commentaire