About Mock Control
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Srinivas_Cool
Posted On:   Wednesday, March 12, 2008 08:15 AM

I have a situation here. We know that whenever MockControls are used, parameters used in the original call either comes from methods' parameter undisturbed or will be a new instantiation. What if the parameters are disturbed and the method call is made?.. can we mock this method?. I have attached a snipnet of code for better understanding. Main class method public void mainMethod(String str,int i) { .. str = str.subIndex(2,5); List work = service1.update(str); .. } JUnit Class MockControl control = createControl(Service1.class); mockObj   More>>

I have a situation here.


We know that whenever MockControls are used, parameters used in the original call either comes from methods' parameter undisturbed or will be a new instantiation.


What if the parameters are disturbed and the method call is made?.. can we mock this method?. I have attached a snipnet of code for better understanding.



Main class method



public void mainMethod(String str,int i)

{

..

str = str.subIndex(2,5);

List work = service1.update(str);

..

}





JUnit Class



MockControl control = createControl(Service1.class);

mockObject = (Service1) control.getMock();




mockObject.update("sampleString");

control.setReturnValue(loadListObjects(),MockControl.ONE_OR_MORE);








I m not able to get the o/p. It says,

assertionFailureError.
Unexpected method call update([])
expected: 0,actual: 1

   <<Less
About | Sitemap | Contact