【发布时间】:2018-08-24 07:32:36
【问题描述】:
我有两个以上类似的 REST ASSURED 休息,例如
@Test
public void makeSureThatGoogleIsUp() {
given().auth().oauth2(getToken()).contentType("application/json")
.when()
.get("http://www.google.com")
.then()
.statusCode(200);
}
@Test
public void makeSureThatGoogleIsUp() {
given().auth().oauth2(getToken()).contentType("application/json")
.when()
.get("https://stackoverflow.com")
.then()
.statusCode(200);
}
我想创建一个名为 given() 的方法,以降低方法的复杂性和可读性。
private [something] given(){
return given().auth().oauth2(getToken()).contentType("application/json")
}
让我的方法使用我给定的而不是放心的方法:
@Test
public void makeSureThatGoogleIsUp() {
given()
.when()
.get("http://www.google.com")
.then()
.statusCode(200);
}
@Test
public void makeSureThatGoogleIsUp() {
given()
.when()
.get("https://stackoverflow.com")
.then()
.statusCode(200);
}
类似这里的东西:但我真的不知道这个方法可以有什么样的返回类型,或者它是否可能。 抱歉,问题可能很琐碎,但说真的,我被困在这里。 有什么帮助吗?谢谢! :)
【问题讨论】:
标签: java spring testing java-8 rest-assured