Robospice-retrofit testing

I am trying to do some unit testing using this robospice-retofit example . The problem is that I got some NullPointerException when I call the loadDataFromNetwork () method. Here's the test code

public class SampleRetrofitSpiceRequestTest extends InstrumentationTestCase {

private SampleRetrofitSpiceRequest sampleRetrofitSpiceRequest;

@Override
protected void setUp() throws Exception {
    super.setUp();
    sampleRetrofitSpiceRequest = new SampleRetrofitSpiceRequest(
            "octo-online", "robospice");
}

public void test_loadDataFromNetwork() throws Exception {
    List contributors = sampleRetrofitSpiceRequest.loadDataFromNetwork();
    assertTrue(contributors.size() > 0);
}
}

      

+3


source to share


1 answer


RetrofitSpiceRequest

you need to modify the instance of the service class (in your case, the GitHub class) to work. Call sampleRetrofitSpiceRequest.setService(...)

with the appropriate argument before calling loadDataFromNetwork

.



0


source







All Articles