Commit e123db8f authored by 赵然's avatar 赵然

Merge branch 'master' of gitlab2.dui88.com:mabo/test-platform

parents a0005406 c6d89476
......@@ -9,17 +9,15 @@ import http.service.app.tawService;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DappConfigService;
import org.apache.logging.log4j.core.pattern.AbstractStyleNameConverter;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.*;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;
import utils.RedisUtil;
......@@ -68,6 +66,32 @@ public class 兑吧新优惠券_兑换流程测试_ExchangeTest extends CheckTem
}
@BeforeMethod
public void before(){
try {
//更新数据表 每人限购批次限制测试
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = 32514");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = 32514");
//更新数据表,每人限购永久限制测试
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = 32513");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = 32513");
//更新数据表,每人限购每日限制测试
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = 32512");
//更新数据表,每日限量测试
jdbc.update("DELETE FROM goods.tb_everyday_limit WHERE item_id = 32515");
} catch (SQLException e) {
e.printStackTrace();
}
}
@Test(description = "兑吧新优惠券每人限购每日")
public void 每人限购每日限制测试() throws Exception {
......@@ -77,55 +101,45 @@ public class 兑吧新优惠券_兑换流程测试_ExchangeTest extends CheckTem
Map cookies = authorization.dafuwengLogin(uid);
String message = "";
try{
//第一次兑换
Response response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
//第一次兑换
Response response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
logger.info("订单状态status:" + status);
Assert.assertEquals(status,"success","校验轮询结果status失败");
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("今日已达兑换上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"今日已达兑换上限","校验兑换按钮失败");
logger.info("校验优惠券每人限购每日限制成功");
}catch (Exception e){
status = response.jsonPath().getString("data.status");
i--;
}
logger.info("订单状态status:" + status);
Assert.assertEquals(status,"success","校验轮询结果status失败");
throw new Exception("异常信息打印:" + e);
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("今日已达兑换上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"今日已达兑换上限","校验兑换按钮失败");
logger.info("校验优惠券每人限购每日限制成功");
}
......@@ -140,55 +154,44 @@ public class 兑吧新优惠券_兑换流程测试_ExchangeTest extends CheckTem
Map cookies = authorization.dafuwengLogin(uid);
String message = "";
try{
//第一次兑换
Response response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
//第一次兑换
Response response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
Assert.assertEquals(status,"success","校验轮询结果status失败");
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("已达兑换次数上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
logger.info("校验优惠券每人限购永久限制成功");
}catch (Exception e){
status = response.jsonPath().getString("data.status");
i--;
}
Assert.assertEquals(status,"success","校验轮询结果status失败");
throw new Exception("异常信息打印:" + e);
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '"+itemId+"'");
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("已达兑换次数上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"已达兑换次数上限","校验兑换按钮失败");
logger.info("校验优惠券每人限购永久限制成功");
}
......@@ -203,56 +206,45 @@ public class 兑吧新优惠券_兑换流程测试_ExchangeTest extends CheckTem
Map cookies = authorization.dafuwengLogin(uid);
String message = "";
try{
//第一次兑换
Response response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
//第一次兑换
Response response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
Assert.assertEquals(status,"success","校验轮询结果status失败");
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("该批次已达兑换上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
//按钮文案不变
Assert.assertEquals(exchangeText,"该批次已达兑换上限","校验兑换按钮失败");
logger.info("校验优惠券每人限购批次限制成功");
}catch (Exception e){
status = response.jsonPath().getString("data.status");
i--;
}
Assert.assertEquals(status,"success","校验轮询结果status失败");
throw new Exception("异常信息打印:" + e);
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '"+itemId+"'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '"+itemId+"'");
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("该批次已达兑换上限"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
//按钮文案不变
Assert.assertEquals(exchangeText,"该批次已达兑换上限","校验兑换按钮失败");
logger.info("校验优惠券每人限购批次限制成功");
}
......@@ -267,55 +259,44 @@ public class 兑吧新优惠券_兑换流程测试_ExchangeTest extends CheckTem
Map cookies = authorization.dafuwengLogin(uid);
String message = "";
try{
//第一次兑换
Response response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
//第一次兑换
Response response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
String orderId = response.jsonPath().getString("data.orderId");
//获取兑换结果
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
String status = response.jsonPath().getString("data.status");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = tawService.orderStatus(orderId,uid);
response.prettyPrint();
status = response.jsonPath().getString("data.status");
i--;
}
Assert.assertEquals(status,"success","校验轮询结果status失败");
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("商品售罄"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"每日限量已兑完","校验兑换按钮失败");
logger.info("校验优惠券每日限量成功");
}catch (Exception e){
status = response.jsonPath().getString("data.status");
i--;
}
Assert.assertEquals(status,"success","校验轮询结果status失败");
throw new Exception("异常信息打印:" + e);
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("商品兑换按钮:" + exchangeText);
}finally {
jdbc.update("DELETE FROM goods.tb_everyday_limit WHERE item_id = '"+itemId+"'");
//第二次兑换
Thread.sleep(3000);
try{
response = gawService.couponExchange(cookies,appItemId,itemId,skuId);
response.prettyPrint();
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("商品售罄"),"校验message失败");
Assert.assertTrue(message.contains("\"success\":false"),"校验success失败");
Assert.assertEquals(exchangeText,"每日限量已兑完","校验兑换按钮失败");
logger.info("校验优惠券每日限量成功");
}
......
......@@ -115,7 +115,7 @@ public class 积分夺宝开奖_AccessTest extends DuibaTestBase {
//同一用户并发领奖 【自动化勿动】lv测试优惠券
@Test(threadPoolSize = 5, invocationCount =5)
public void 夺宝单用户并发领奖() throws Exception {
public void A_夺宝单用户并发领奖() throws Exception {
int uid = 7397;
String activityId = "45465";
String detailId = "8";
......@@ -135,7 +135,8 @@ public class 积分夺宝开奖_AccessTest extends DuibaTestBase {
resultList.add(rewardResponse.asString());
logger.info("请求返回结果:" + rewardResponse.asString());
}
@Test(dependsOnMethods = "夺宝单用户并发领奖")
@Test(dependsOnMethods = "A_夺宝单用户并发领奖")
public void checkResult(){
int fail = 0;
int success = 0;
......@@ -177,7 +178,7 @@ public class 积分夺宝开奖_AccessTest extends DuibaTestBase {
String prizeCode = String.valueOf(detailResponse.jsonPath().getString("data.prizeCode"));
Assert.assertEquals(prizeType,"object","校验prizeType失败");
Assert.assertEquals(rewardStatus,"1","校验rewardStatus失败");
Assert.assertEquals(rewardStatus,"3","校验rewardStatus失败"); //奖品过期了未领取
Assert.assertEquals(prizeCode,"887316214305","校验prizeCode失败");
//校验领奖后的页面跳转链接
......
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