我正在使用Restassured和TestNG框架测试Weather Rest API。以下是代码: 我确保已将所有依赖项包含在pom.xml文件中 这是错误:
java.lang.NoSuchMethodError: org.testng.remote.AbstractRemoteTestNG.addListener(Lorg/testng/ISuiteListener;)V
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:122)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:137)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:58)
import org.testng.annotations.Test;
import io.restassured.RestAssured;
import io.restassured.http.Method;
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
public class RestApi_Weather_GET {
@Test
void GetWeatherDetails(){
//specify the base uri
RestAssured.baseURI = "http://restapi.demoqa.com/utilities/weather/city/";
//Request object is being created
RequestSpecification ahttprequest = RestAssured.given();
//Response object
Response aresponse = ahttprequest.request(Method.GET, "Alameda");
//print response in console
String aresponseBody = aresponse.getBody().asString();
System.out.println("Response body is : "+aresponseBody);
}
}