I have the following skeleton of code in a JAVA class called "TestClass.Java":
public String functionA ()
{
If function B() == true)
{
String testVariable = function C();
String test2 = testVariable +"Here a test";
}
else
{
...
}
}
I need to apply unit tests for this function functionA() where tests had been applied on functionB() and functionC(): I did below:
private TestClass mockTestClass ;
@Test
public void testFunctionA()
{
mockTestClass = Mockito.mock(TestClass.class);
private MockComponentWorker mockito;
Mockito.when(mockTestClass.functionB()).thenReturn(true);//already test is done;
Mockito.when(mockTestClass.functionC()).thenReturn("test"); //already test is done;
mockito = mockitoContainer.getMockWorker();
mockito.addMock(TestClass.class,mockTestClass);
mockito.init();
assertEquals("PAssed!", "test Here a test", mockTestClass.functionA());
}
When I ran my test, I got: NULL in mockTestClass.functionA(). Can you please help? How to test this function?
thanks,
Rosy
Aucun commentaire:
Enregistrer un commentaire