我使用Retrofit为我的REST API实现了一个Java客户端。客户端是一个简单的Java应用程序,而不是Android应用程序。如何为Java客户端编写单元测试?以下是我的服务类之一。
public interface CountryService {
/**
* Returns country list.
*
* @param sortby
* Optional; Sorting order of list. Pass null to ignore.
*
* @return Countries object with list of countries.
*
* @throws SRSRetrofitException
*/
@GET(SRSClientConstants.SLASH + SRSClientConstants.RESOURCE_COUNTRY)
public Countries getCountries(@Query("sortby") String sortby)
throws SRSRetrofitException;
}
答案 0 :(得分:-1)
使用在线托管的REST应用程序,您只需使用GET / POST和其他HTTP方法来查询服务。不需要特殊构造。尝试发送包含所有有效参数的HTTP请求。它应该工作。有关REST click here
的更多信息