开发者

JMock Allow Other Method Calls

开发者 https://www.devze.com 2023-02-18 19:17 出处:网络
I\'m using JMock to test the behavior of a class using an object. I want to t开发者_Python百科est that the method a() is called. However, b() and c() also are called on the object too. Therefore if my

I'm using JMock to test the behavior of a class using an object. I want to t开发者_Python百科est that the method a() is called. However, b() and c() also are called on the object too. Therefore if my expectations expect a(), it must also expect b() and c() to make the test pass. Is there a way to test only for a certain method, and allow anything else?


Expect a() allow only methods b() & c()

mockery.checking(new Expectations() {{
    one(mockObject).a();

    allowing(mockObject).b();
    allowing(mockObject).c();
}});

Expect a() allow all other methods.

mockery.checking(new Expectations() {{
    one(mockObject).a();

    allowing(mockObject);
}});
0

精彩评论

暂无评论...
验证码 换一张
取 消