문제

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top