3

I'm trying to do some unit-testing using this robospice-retofit example. The problem is i got some NullPointerException when I call the loadDataFromNetwork() method. Here's the testing 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);
}
}

1 Answers1

0

RetrofitSpiceRequest needs retrofit service class instance (in your case, GitHub class) to work. Call sampleRetrofitSpiceRequest.setService(...) with appropriate argument before calling loadDataFromNetwork.

Deinlandel
  • 1,023
  • 8
  • 25