@Rhys No es el JUnit4Mockery
que reemplaza la necesidad de llamar assertIsSatisfied
, es el JMock.class
(combinado con el @RunWith
). No necesitará llamar al assertIsSatisfied
cuando cree un Mockery
normal.
El JUnit4Mockery
traduce los errores.
Por defecto, se presentan excepciones expectativa en Junit como ExpectationError
, así por ejemplo, el uso de
Mockery context = new Mockery();
obtendrá
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?
y usar,
Mockery context = new JUnit4Mockery();
que
Obtendrá
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!
El JUnit4Mockery convirtió el ExpectationError en un java.lang.AssertionError con el que JUnit trata. El resultado neto es que aparecerá en su informe JUnit como un error (usando JUnit4Mockery) en lugar de un error.
Creo que fue mi confusión también. – time4tea