Not sure about Scala, but are you missing the double '{{' '}}' syntax? We're very sorry about it, but it's the best we could do in Java.
The outer '{}' is an anonymous subclass, and the inner '{}' is an initialisation block.
Вопрос
I'm new to JMock and trying to get a simple unit test working through Scala. The test is mocking an interface and then setting some xpectations before executing a method on the mocked interface.
val context = new Mockery
val mockObj= context.mock(classOf[SomeClassInterface])
@Test def sometest = {
context.checking(
new Expectations() {
allowing (mockObj).doFunc1();
will(returnValue(someResponse);
allowing (mockObj).doFunc2(someResponse);
will(returnValue(someResponse));
allowing (mockObj).doFunc3(someResponse);
will(returnValue("Enabled"));
}
)
var status:String = mockObj.doSomething()
//context.assertIsSatisfied();
Assert.assertTrue(status.equalsIgnoreCase("Enabled"))
}
This results in the error;
unexpected invocation; mockObj.doSomething() ......... what happened before this; nothing!
Any ideas what is going wrong?
Решение
Not sure about Scala, but are you missing the double '{{' '}}' syntax? We're very sorry about it, but it's the best we could do in Java.
The outer '{}' is an anonymous subclass, and the inner '{}' is an initialisation block.