我正在按照本教程http://dextra.com.br/en/blog/automacao-de-api-rest-using-java-andrestassured/学习如何测试api以及在运行时出现以下错误:
java.lang.ClassNotFoundException:org.codehaus.groovy.runtime.callsite.CallSiteArray
我导入了测试所需的所有库,但仍然无法正常工作。
package br.com.automation.APIRest;
import static io.restassured.RestAssured.*;
import io.restassured.http.ContentType;
import static org.hamcrest.Matchers.*;
import org.junit.Test;
public class TestAPI {
@Test
public void Teste() {
String uriBase = "https://postman-echo.com/get";
given()
.relaxedHTTPSValidation()
.param("foo1", "bar1")
.param("foo2", "bar2")
.when()
.get(uriBase)
.then()
.statusCode(200) // O status http retornado foi 200
.contentType(ContentType.JSON) // O response foi retornado no formato JSON
.body("headers.host", is("postman-echo.com")) // A chave "host" possui exatamente o valor "postman-echo.com"
.body("args.foo1", containsString("bar")); //A chave "foo1" contém o valor "bar"
}
}
罐子