我正在尝试使用 REST 确保来测试我的登录/注销功能。是否可以进行一个 REST 保证的测试,先登录然后再注销?如果没有,我怎样才能正确测试它?
只需发送两个post()与一个assert()/expect() :
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.Matchers.*;
import static com.jayway.restassured.RestAssured.*;
@Test
public void loginAndLogout(){
final String login = randomLogin();
// First post to login()
given()
.queryParam("login", login)
.queryParam("password", randomPassword())
.when().post("/login/");
// Second post to logout() with an assert
expect().statusCode(200)
.given()
.when().post("/logout/");
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)