Hi,
I am facing a prob while mocking a concrete class.
I am giving a simplified version of the prob.
In the given testcase,
its trying to run the method, when i call mockery.checking().
Is it an expected behaviour?
Because of this,
i am not able to use mocking of a concrete class.
I am using JMock 2.4.0.
Thanks,
avinash
package com.nayak;
public class OpClass {
public final void execute(boolean validate) {
System.out.println("In execute() : " + validate);
if (validate)
validate();
}
private void validate() {
// No Validations done
System.out.println("In validate()");
}
}
package com.nayak;
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.lib.action.VoidAction;
import org.jmock.lib.legacy.ClassImposteriser;
import
junit.framework.TestCase;
public class OpClassUTEST extends TestCase {
public void testExecute() {
Mockery mockery = new Mockery();
mockery.setImposteriser(ClassImposteriser.INSTANCE);
final OpClass opClass = mockery.mock(OpClass.class);
mockery.checking(new Expectations() {
{
one(opClass).execute(with(any(Boolean.class)));
will(VoidAction.INSTANCE);
}
});
mockery.assertIsSatisfied();
}
}
Output : "In execute() : false"
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email