Using jMock, how do I test that all methods of a certain class is not called upon invoking a method in another class?
For example, if I have class A and class B:
class A {
void x() {
}
void y() {
}
void z() {
}
}
class B {
A a;
void doNothing() {
}
}
How do I test that the invocation of B#doNothing() doesn't invoke any of class A's method?
I know that with jMock 2 and JUnit 3, I can do:
public class BTest extends MockObjectTestCase {
@Test
public void testDoNothing() {
B b = new B();
A a = b.getA();
checking(new Expectations() {{
never(a).x();
never(a).y();
never(a).z();
}});
b.doNothing();
}
}
But what if there is more than just 3 methods, say 30? How would I test that?
First off, I believe that is will in fact match what you want:
However, if that doesn't work, this should: