Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马博
test-platform
Commits
1a422e94
Commit
1a422e94
authored
Mar 13, 2019
by
吕雯燕
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'duiba_wenyan' into develop
parents
7006e73a
d45778de
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
128 additions
and
2 deletions
+128
-2
话费_兑换限制测试_ExchangeTest.java
.../java/http/cases/ExchangeTest/话费_兑换限制测试_ExchangeTest.java
+128
-2
No files found.
src/test/java/http/cases/ExchangeTest/话费_兑换限制测试_ExchangeTest.java
View file @
1a422e94
...
...
@@ -8,11 +8,17 @@ import io.restassured.response.Response;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.DataProvider
;
import
org.testng.annotations.Test
;
import
utils.MatcherString
;
import
java.lang.reflect.Method
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
io
.
restassured
.
RestAssured
.
given
;
/**
* Created by mabo on 2019/2/28
*/
...
...
@@ -21,25 +27,40 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{
private
MobileService
mobileService
;
@Autowired
private
Authorization
authorization
;
//指定用户 hd:13193311222
private
static
int
uid
=
6537
;
@Autowired
private
CouponExchangeService
couponExchangeService
;
@Autowired
private
CrecordService
crecordService
;
//指定用户 hd:13193311222
private
static
int
uid
=
6537
;
private
String
url
=
"http://activity.m.duibatest.com.cn"
;
@BeforeMethod
public
void
beforeMethod
(){
try
{
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record where item_id=1662 and consumer_id = 100136046"
);
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record where item_id=1663 and consumer_id = 100136046"
);
jdbc
.
update
(
"DELETE FROM credits_dev.consumer_limit_record_only where item_id=1663 and consumer_id = 100136046"
);
jdbc
.
update
(
"DELETE FROM goods.tb_everyday_limit where item_id = 1664"
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
@DataProvider
public
Object
[][]
providerMethod
(
Method
method
)
{
Object
[][]
result
=
null
;
if
(
method
.
getName
().
equals
(
"兑换日期限制测试"
))
{
result
=
new
Object
[][]{
new
Object
[]{
1
,
"191795"
,
"1661"
,
"2"
,
"话费兑换日期限制未开始测试"
},
//case1,2元话费
new
Object
[]{
3
,
"191792"
,
"1665"
,
"50"
,
"话费兑换日期限制已结束测试"
},
//case3,50元话费
};
}
return
result
;
}
@Test
(
description
=
"每个用户每日兑换限制"
)
...
...
@@ -81,6 +102,8 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{
Assert
.
assertTrue
(
e
.
getMessage
().
contains
(
"今日已达兑换上限"
),
"校验每日限制势失败"
);
}
}
@Test
(
description
=
"永久兑换限制"
)
public
void
phonebill_
永久
()
throws
Exception
{
Thread
.
sleep
(
2000
);
...
...
@@ -120,4 +143,107 @@ public class 话费_兑换限制测试_ExchangeTest extends CheckTemplet{
Assert
.
assertTrue
(
e
.
getMessage
().
contains
(
"已达兑换次数上限"
),
"校验永久限制失败"
);
}
}
@Test
public
void
每日兑换上限测试
()
throws
Exception
{
String
appItemId
=
"191793"
;
String
itemId
=
"1664"
;
//20元话费兑换
Response
response
=
couponExchangeService
.
phonebillExchange
(
authorization
.
dafuwengLogin
(
uid
),
appItemId
,
itemId
,
"20"
);
response
.
prettyPrint
();
String
orderId
=
response
.
jsonPath
().
getString
(
"orderId"
);
String
message
=
response
.
jsonPath
().
getString
(
"message"
);
int
i
=
10
;
//异步接口,兑换提交成功!待处理
while
(
i
>
0
&&
"兑换正在处理中..."
.
equals
(
message
))
{
Thread
.
sleep
(
1000
);
response
=
mobileService
.
orderStatusQuery
(
response
.
getDetailedCookies
(),
uid
,
orderId
);
response
.
prettyPrint
();
message
=
response
.
jsonPath
().
getString
(
"message"
);
i
--;
}
Response
detailResponse
=
mobileService
.
detail
(
authorization
.
dafuwengLogin
(
uid
),
itemId
);
String
exchangeText
=
MatcherString
.
getString
(
detailResponse
.
asString
(),
"\"exchangeText\":\"(.*?)\","
,
1
);
logger
.
info
(
"商品兑换按钮:"
+
exchangeText
);
//第二次兑换
try
{
response
=
couponExchangeService
.
phonebillExchange
(
authorization
.
dafuwengLogin
(
uid
),
appItemId
,
itemId
,
"20"
);
response
.
prettyPrint
();
}
catch
(
Exception
e
){
message
=
e
.
toString
();
}
logger
.
info
(
message
);
Assert
.
assertTrue
(
message
.
contains
(
"今日已兑完,明天再来哦(14)"
),
"校验message失败"
);
Assert
.
assertTrue
(
message
.
contains
(
"\"success\":false"
),
"校验success失败"
);
Assert
.
assertEquals
(
exchangeText
,
"每日限量已兑完"
,
"校验兑换按钮失败"
);
logger
.
info
(
"校验话费每日兑换上限成功"
);
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param degreeId 档位
* @param caseName 用例名称打印
* @throws Exception
*/
@Test
(
dataProvider
=
"providerMethod"
)
public
void
兑换日期限制测试
(
int
caseNum
,
String
appItemId
,
String
itemId
,
String
degreeId
,
String
caseName
)
throws
Exception
{
logger
.
info
(
caseName
);
String
message
=
""
;
try
{
Response
response
=
couponExchangeService
.
phonebillExchange
(
authorization
.
dafuwengLogin
(
uid
),
appItemId
,
itemId
,
degreeId
);
response
.
prettyPrint
();
}
catch
(
Exception
e
){
message
=
e
.
toString
();
}
logger
.
info
(
"兑换结果:"
+
message
);
//获取按钮状态
Response
detailResponse
=
mobileService
.
detail
(
authorization
.
dafuwengLogin
(
uid
),
itemId
);
String
exchangeText
=
MatcherString
.
getString
(
detailResponse
.
asString
(),
"\"exchangeText\":\"(.*?)\","
,
1
);
logger
.
info
(
"商品兑换按钮:"
+
exchangeText
);
switch
(
caseNum
){
case
1
:
Assert
.
assertTrue
(
message
.
contains
(
"请在限定时间内兑换哦(13)"
),
"校验message失败"
);
Assert
.
assertEquals
(
exchangeText
,
"即将开始"
,
"校验马上兑换按钮状态失败"
);
logger
.
info
(
"校验话费兑换日期限制未开始成功"
);
break
;
case
2
:
Assert
.
assertTrue
(
message
.
contains
(
"已结束"
),
"校验message失败"
);
Assert
.
assertEquals
(
exchangeText
,
"已结束"
,
"校验马上兑换按钮状态失败"
);
logger
.
info
(
"校验话费兑换日期限制已结束成功"
);
break
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment