I would like to create a unit test that verifies that the api successfully gets the List of Repos. I would like that the test actually makes the network connection instead of using a Mock Server. And also would be good to use RoboElectric for example so the test can run on the JVM.
This to test the Model from the MVP architecture. I am using a sample project from Mosby , this uses Dagger 2 and Retrofit 1.9
public interface GithubApi {
@GET("/repositories")
@Headers("Cache-Control: no-cache")
public void getRepos(Callback<List<Repo>> callback);
}
This is the module
@Module(
)
public class SampleModule {
@Provides @Singleton public GithubApi providesGithubApi() {
OkHttpClient client = new OkHttpClient();
client.setCache(new Cache(context.getCacheDir(), 10 * 1024 * 1024));
RestAdapter restAdapter = new RestAdapter.Builder()
.setClient(new OkClient(client))
.setEndpoint("https://api.github.com")
.build();
return restAdapter.create(GithubApi.class);
}
}
Aucun commentaire:
Enregistrer un commentaire