mercredi 2 mars 2016

Android Unit Test with Retrofit2 and Mockito

Can i use Mockito to test real response from retrofit2beta4? I don't have activities in my project, it will be a library and i need to test is server responding correctly. Now i have such code and stuck...

@Mock
ApiManager apiManager;

@Captor
private ArgumentCaptor<ApiCallback<Void>> cb;

@Before
public void setUp() throws Exception {
    apiManager = ApiManager.getInstance();
    MockitoAnnotations.initMocks(this);
}

@Test
public void test_login() {
    Mockito.verify(apiManager).loginUser(Mockito.eq(login), Mockito.eq(pass), cb.capture());

//        cb.getValue();
//        assertEquals(cb.getValue().isError(), false);
}

I can make fake response, but i need to test real. Is it success? Is it's body correct? Can you help me with code?

Aucun commentaire:

Enregistrer un commentaire