dcsimg
how to mock a same method
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   mahesh_kankanala
Posted On:   Wednesday, September 28, 2005 05:16 AM

public class HowToMockASameMethod { public void abc() { int x = xxx.getValue(); // suppose here i am getting the value "100" } public void cba(); { int y = xxx.getValue(); //// suppose here i am getting the value "200" } } HOW TO MOCK THE xxx.getValue() Method HERE MY CODE public class ThisIsMyMockClass extends TestCase { public void test() { mock.expects(atLeastOnce()).method("getValue") .will(returnValue(100),returnValue(200)); } } I MY QUESTIN IS HERE HOW TO MOCK THE GETVALUE METHOD, IT SHOULD RETURN TWO DIFFERENT VALUES.    More>>


public class HowToMockASameMethod {

public void abc()
{
int x = xxx.getValue(); // suppose here i am getting the value "100"
}

public void cba();
{
int y = xxx.getValue(); //// suppose here i am getting the value "200"
}
}



HOW TO MOCK THE xxx.getValue() Method



HERE MY CODE


public class ThisIsMyMockClass extends TestCase
{
public void test()
{

mock.expects(atLeastOnce()).method("getValue")
.will(returnValue(100),returnValue(200));
}
}

I MY QUESTIN IS HERE HOW TO MOCK THE GETVALUE METHOD, IT SHOULD RETURN TWO DIFFERENT VALUES.

   <<Less
About | Sitemap | Contact