Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to stub a method which is called from within the 'method under test' ? #29

Open
srgiri opened this issue Nov 2, 2017 · 1 comment

Comments

@srgiri
Copy link

srgiri commented Nov 2, 2017

Hi,
I have a question on method stubbing. Let's say I want to generate test cases for a method 'testMe(int x, int y)'. And 'testMe()' calls another method 'halfValue(int x)'. I do not want JDart to go inside 'halfValue()' method. Is there anything in JDart which can stub 'halfValue()' ?

public void testMe(int x, int y){
  //do something
  int z = halfValue(y);
  if(z > 10  /* && few more conditions */){
    //do something
  }else{
    //do something
  }
  //do something
}

public int halfValue(int x){
  return x/2;
}

Please note: the halfValue() method works on the input 'y' and the condition in testMe() is based on the returned value from halfValue() method.

Thanks,
S. R. Giri

@srgiri
Copy link
Author

srgiri commented Apr 10, 2018

In continuation to the above question, Is there any way to by pass the execution of the method 'halfValue()' ? Means without executing the definition of 'halfValue()' can I be able to generate test cases for the calling method i.e. 'testMe()'.
This kind of situation may arise when the method 'halfValue()' would be inside an external jar file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant