Tag: 放心

restAssured – 不能掌握post方法

同胞stackoverflowians 🙂 我一直在用戒烟的时间来使用Gmail API进行邮寄。 一直试图使用createDraft和createLabel。 现在我想我已经找到了正确的(主要)如何做到这一点,但我得到这个错误: java.lang.AssertionError: 1 expectation failed. Expected status code <200> but was <400>. 我意识到发生这个错误,因为我做出不正确的请求。 你能帮我一下吗? 这是我的代码: import io.restassured.RestAssured.* import io.restassured.http.ContentType import io.restassured.matcher.RestAssuredMatchers.* import org.hamcrest.Matchers.* import org.testng.annotations.Test class RestAPIAutoTestPost { @Test fun createLabelInGoogleMail() { RestAssured.baseURI = "https://www.googleapis.com/gmail/v1/users/me" val accessToken = "ya29.Glw7BEv6***" val jsonAsMap = HashMap<String, Any>() jsonAsMap.put("id", "labelAPITestNameID") jsonAsMap.put("labelListVisibility", "labelShow") jsonAsMap.put("messageListVisibility", "show") […]

RestAssured-身体中的对象抛出错误

我通过测试的对象 @Data public class UserRequest { @JsonProperty("name") private final String name; @JsonProperty("surname") private final String surname; @JsonProperty("email") private final String email; @JsonProperty("iaAdmin") private final boolean isAdmin; } 比我有它测试 @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class UserControllerIT { @LocalServerPort private int port; @Test public void testIsCreatingNewUser() throws IOException{ given() .when() .body(new UserRequest("asd","sad","asd",false))//.body(TestGenerator.getUserRequest()) .port(port) .post("/user/" + TestGenerator.randomUUID) .then() […]

写作单元在Kotlin测试,共享变量?

我正在尝试在Kotlin中创建一些功能测试,以使用Rest Assured库向购物车Java服务器发出请求。 因为我希望测试的行为程序,我希望我可以存储第一个A​​PI请求的结果,并将其传递到下一个单元测试。 即 createCartTest() – > cartId – > getCartForWebsiteTest(cartId) class CartTest : RestAssuredSupport { val port = 8080 val url = "http://localhost:" val cartId = null /** * Create a cart object */ @Test fun createCartTest() { given(). now(). body("websiteId=1"). contentType(ContentType.URLENC). post(url + port + "/orders/cart/create.do"). then(). statusCode(200). body("summary.numItems", equalTo(0)). body("summary.visibleNumItems", equalTo(0)). body("summary.cartId", […]