vendredi 12 avril 2019

Mocking aggregate classes

we have the following method inside class C:

public static void m(a A)
{
......

A1 a1=new a.getA1;  //Not sure about the syntax
Double d1= a.getInfo;
.....
}

A is another class. Inside A, we have a variable declared as type of class A1 (this makes A an aggregated class I think). I have defined the following as mock objects:

private mockA = mock(A.class);
private mockA1 = mock(A1.class);   // Please help with syntax

Also

when(mockA.getInfo()).thenReturn(6.4);
when(mockA.getA1()).thenReturn(mockA1);    //Please help with syntax
when(mockA1.m2()).thenReturn("Some More Details");   // Please help with syntax 

Could you please help if the syntax for mocking A1 object and using it in when is correct? Thanks

Aucun commentaire:

Enregistrer un commentaire