mardi 3 mars 2020

Which kind of java unit test I can write for an API CALL?

I have written my android app that get the weather from every city of the world using API CALL like these:

public interface WeatherAPI {


String BASE_URL = "http://api.openweathermap.org/";
String API_KEY = "3ea610fb4c761b449fd66636cdf761a7";
String UNITS_METRIC = "metric";

@GET("data/2.5/weather")
Call<Response> getWeather(@Query("q") String query,@Query("appid") String appId,@Query("units") String units);


class Factory {
    private static WeatherAPI service;
    public static WeatherAPI getInstance() {
        if (service == null) {
            Retrofit retrofit = new Retrofit.Builder()
                    .addConverterFactory(GsonConverterFactory.create())
                    .baseUrl(BASE_URL)
                    .build();
            service = retrofit.create(WeatherAPI.class);
            return service;
        } else {
            return service;
        }
    }
}

}

With other classes that modeling the incoming data, and a MainActivity that just receives the city name and displays the results on the screen.

Could you help me? Thanks

Aucun commentaire:

Enregistrer un commentaire