I am currently writing unit testcase for a groovy application
class Page{
..
..
str1 = obj.getDateBasedOnValue("A");
str2 = obj.getDateBasedOnValue("B");
}
Test class
class PageSpec extends Specification{
Obj obj = Mock(Obj)
...
def "testCase 1"(){
obj.getDateBasedOnValue(_) >> "some date string 1"
obj.getDateBasedOnValue(_) >> "some date string 2"
}
}
Can someone tell me if this is the right way to mock both the calls in spock? If no then please guide me towards the right solution.