@Rhys Non è la JUnit4Mockery
che sostituisce la necessità di chiamare assertIsSatisfied
, il suo JMock.class
(combinato con il @RunWith
). Non è necessario chiamare assertIsSatisfied
quando si crea un regolare Mockery
.
Il JUnit4Mockery
traduce gli errori.
Per impostazione predefinita, le eccezioni di aspettativa sono riportati in Junit come ExpectationError
, quindi, ad esempio, utilizzando
Mockery context = new Mockery();
si otterrà
unexpected invocation: bar.bar()
no expectations specified: did you...
- forget to start an expectation with a cardinality clause?
- call a mocked method to specify the parameter of an expectation?
e l'utilizzo,
Mockery context = new JUnit4Mockery();
voi otterrò
java.lang.AssertionError: unexpected invocation: bar.bar()
no expectations specified: did you...
- forget to start an expectation with a cardinality clause?
- call a mocked method to specify the parameter of an expectation?
what happened before this: nothing!
JUnit4Mockery ha convertito l'ExpectationError in un oggetto java.lang.AssertionError che JUnit gestisce. Il risultato netto è che verrà visualizzato nel report JUnit come errore (utilizzando JUnit4Mockery) anziché un errore.
Penso che era la mia confusione troppo. – time4tea