I need to test if the boolean value returned by the checkIt function when I call Myfunction with hello, it should return true.
public class Myclass
{
public void Myfunction(x)
{
if(x!= null)
{
boolean containsHello;
containsHello = checkIt(x)
}
Rest of the statements for Myfunction -------
goes here -------
}
@VisibleForTesting
boolean checkIt(String x)
{
return x.contains('hello');
}
I want to unit test if the checkIt function returns true when I pass 'hello' to Myfunction in Mockito. I tried the below code but it does not seem to work
String loc = Mockito.spy('hello');
Mockito.verify(Myclass).checkIt(x);
Assert.assertEquals(true, checkIt(loc));
Aucun commentaire:
Enregistrer un commentaire