Skip to content

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

@srgiri

Description

@srgiri

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions