Commit aa509f88 authored by 马博's avatar 马博

restassert 升级

加响应超时时间
parent 8e9ed3ec
......@@ -65,7 +65,7 @@
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>3.0.3</version>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
......
package base;
import io.restassured.RestAssured;
import org.apache.http.client.params.ClientPNames;
import org.apache.http.params.CoreConnectionPNames;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
......@@ -8,6 +11,9 @@ import org.testng.annotations.BeforeSuite;
import javax.annotation.PostConstruct;
import static io.restassured.RestAssured.config;
import static io.restassured.config.HttpClientConfig.httpClientConfig;
/**
* Created by mabo on 2018/9/20
*/
......@@ -25,6 +31,11 @@ public class DuibaBase extends AbstractTestNGSpringContextTestsDuiba {
logger.info("--------------------DuibaBase.setUp() Tests");
//只初始化一次
jdbc.initDataSource();
//设置接口响应超时时间
RestAssured.config = RestAssured.config().httpClient(httpClientConfig()
.setParam(ClientPNames.CONN_MANAGER_TIMEOUT, Long.valueOf(5000)) // HttpConnectionManager connection return time
.setParam(CoreConnectionPNames.CONNECTION_TIMEOUT, 5000) // Remote host connection time
.setParam(CoreConnectionPNames.SO_TIMEOUT, 10000));// Remote host response time
}
......
......@@ -18,10 +18,16 @@ public class CheckTemplet extends DuibaBase {
@BeforeSuite
public void setTemplet() throws Exception {
try{
logger.info("------------------------setTemplet()");
this.setVirtual();
Thread.sleep(1000);
this.setQb();
}catch (Exception e){
e.printStackTrace();
}
}
public void setVirtual() throws Exception {
......
......@@ -332,8 +332,8 @@ public class 自有新优惠券_兑换限制测试 extends CheckTemplet{
case 3:
// Assert.assertEquals(response.jsonPath().getString("message"),"已结束","校验日期兑换限制失败");
Assert.assertTrue(message.contains("已结束"),"校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"已结束","校验马上兑换按钮状态失败");
Assert.assertTrue(message.contains("限2019-03-27至2019-03-27日期内兑换"),"校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"限2019-03-27至2019-03-27日期内兑换","校验马上兑换按钮状态失败");
logger.info("校验实物日期兑换限制已结束成功");
break;
......
......@@ -3,7 +3,10 @@ package http.cases.ExchangeTest.自有_商品兑换限制;
import http.cases.ExchangeTest.CheckTemplet;
import http.service.Authorization;
import http.service.app.MobileService;
import io.restassured.RestAssured;
import io.restassured.response.Response;
import org.apache.http.client.params.ClientPNames;
import org.apache.http.params.CoreConnectionPNames;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
......@@ -14,6 +17,11 @@ import utils.MatcherString;
import java.lang.reflect.Method;
import java.sql.SQLException;
import static io.restassured.RestAssured.config;
import static io.restassured.RestAssured.given;
import static io.restassured.config.HttpClientConfig.httpClientConfig;
import static io.restassured.config.RestAssuredConfig.newConfig;
/**
* Created by mabo on 2019/3/26
*/
......@@ -47,6 +55,12 @@ public class 自有新卡密_兑换限制测试 extends CheckTemplet {
}
// @Test
// public void test(){
//
// Response response = given().get("http://localhost:1112/sql/test");
// response.prettyPrint();
// }
@DataProvider
public Object[][] providerMethod(Method method) {
......
......@@ -317,8 +317,8 @@ public class 自有新虚拟商品_充值_兑换限制 extends CheckTemplet{
case 1:
// Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验日期兑换限制失败");
Assert.assertTrue(message.contains("限2019-03-28至2032-04-30日期内兑换"),"校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"限2019-03-28至2032-04-30日期内兑换","校验马上兑换按钮状态失败");
Assert.assertTrue(message.contains("限2030-03-29至2032-04-29日期内兑换"),"校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"限2030-03-29至2032-04-29日期内兑换","校验马上兑换按钮状态失败");
logger.info("校验实物日期兑换限制未开始成功");
break;
......@@ -331,8 +331,8 @@ public class 自有新虚拟商品_充值_兑换限制 extends CheckTemplet{
case 3:
// Assert.assertEquals(response.jsonPath().getString("message"),"已结束","校验日期兑换限制失败");
Assert.assertTrue(message.contains("已结束"),"校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"已结束","校验马上兑换按钮状态失败");
Assert.assertTrue(message.contains("限2019-03-27至2019-03-27日期内兑换"),"校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"限2019-03-27至2019-03-27日期内兑换","校验马上兑换按钮状态失败");
logger.info("校验实物日期兑换限制已结束成功");
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment