Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 JMock 来测试使用对象的类的行为。我想测试该方法a()是否被调用。但是,b()并且c()也被调用在对象上。因此,如果我的期望期望a(),它也必须期望b()并且c()使测试通过。有没有办法只测试某种方法,并允许其他任何方法?
a()
b()
c()
Expecta()只允许方法b()&c()
mockery.checking(new Expectations() {{ one(mockObject).a(); allowing(mockObject).b(); allowing(mockObject).c(); }});
期望a()允许所有其他方法。
mockery.checking(new Expectations() {{ one(mockObject).a(); allowing(mockObject); }});