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
aa509f88
Commit
aa509f88
authored
Mar 28, 2019
by
马博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restassert 升级
加响应超时时间
parent
8e9ed3ec
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
42 additions
and
11 deletions
+42
-11
pom.xml
pom.xml
+1
-1
DuibaBase.java
src/test/java/base/DuibaBase.java
+11
-0
CheckTemplet.java
src/test/java/http/cases/ExchangeTest/CheckTemplet.java
+10
-4
自有新优惠券_兑换限制测试.java
...java/http/cases/ExchangeTest/自有_商品兑换限制/自有新优惠券_兑换限制测试.java
+2
-2
自有新卡密_兑换限制测试.java
.../java/http/cases/ExchangeTest/自有_商品兑换限制/自有新卡密_兑换限制测试.java
+14
-0
自有新虚拟商品_充值_兑换限制.java
...va/http/cases/ExchangeTest/自有_商品兑换限制/自有新虚拟商品_充值_兑换限制.java
+4
-4
No files found.
pom.xml
View file @
aa509f88
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
<dependency>
<dependency>
<groupId>
io.rest-assured
</groupId>
<groupId>
io.rest-assured
</groupId>
<artifactId>
rest-assured
</artifactId>
<artifactId>
rest-assured
</artifactId>
<version>
3.
0.3
</version>
<version>
3.
3.0
</version>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</dependency>
...
...
src/test/java/base/DuibaBase.java
View file @
aa509f88
package
base
;
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.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.testng.AbstractTestNGSpringContextTests
;
import
org.springframework.test.context.testng.AbstractTestNGSpringContextTests
;
...
@@ -8,6 +11,9 @@ import org.testng.annotations.BeforeSuite;
...
@@ -8,6 +11,9 @@ import org.testng.annotations.BeforeSuite;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
static
io
.
restassured
.
RestAssured
.
config
;
import
static
io
.
restassured
.
config
.
HttpClientConfig
.
httpClientConfig
;
/**
/**
* Created by mabo on 2018/9/20
* Created by mabo on 2018/9/20
*/
*/
...
@@ -25,6 +31,11 @@ public class DuibaBase extends AbstractTestNGSpringContextTestsDuiba {
...
@@ -25,6 +31,11 @@ public class DuibaBase extends AbstractTestNGSpringContextTestsDuiba {
logger
.
info
(
"--------------------DuibaBase.setUp() Tests"
);
logger
.
info
(
"--------------------DuibaBase.setUp() Tests"
);
//只初始化一次
//只初始化一次
jdbc
.
initDataSource
();
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
}
}
...
...
src/test/java/http/cases/ExchangeTest/CheckTemplet.java
View file @
aa509f88
...
@@ -18,10 +18,16 @@ public class CheckTemplet extends DuibaBase {
...
@@ -18,10 +18,16 @@ public class CheckTemplet extends DuibaBase {
@BeforeSuite
@BeforeSuite
public
void
setTemplet
()
throws
Exception
{
public
void
setTemplet
()
throws
Exception
{
logger
.
info
(
"------------------------setTemplet()"
);
try
{
this
.
setVirtual
();
logger
.
info
(
"------------------------setTemplet()"
);
Thread
.
sleep
(
1000
);
this
.
setVirtual
();
this
.
setQb
();
Thread
.
sleep
(
1000
);
this
.
setQb
();
}
catch
(
Exception
e
){
e
.
printStackTrace
();
}
}
}
public
void
setVirtual
()
throws
Exception
{
public
void
setVirtual
()
throws
Exception
{
...
...
src/test/java/http/cases/ExchangeTest/自有_商品兑换限制/自有新优惠券_兑换限制测试.java
View file @
aa509f88
...
@@ -332,8 +332,8 @@ public class 自有新优惠券_兑换限制测试 extends CheckTemplet{
...
@@ -332,8 +332,8 @@ public class 自有新优惠券_兑换限制测试 extends CheckTemplet{
case
3
:
case
3
:
// Assert.assertEquals(response.jsonPath().getString("message"),"已结束","校验日期兑换限制失败");
// Assert.assertEquals(response.jsonPath().getString("message"),"已结束","校验日期兑换限制失败");
Assert
.
assertTrue
(
message
.
contains
(
"
已结束
"
),
"校验日期兑换限制失败"
);
Assert
.
assertTrue
(
message
.
contains
(
"
限2019-03-27至2019-03-27日期内兑换
"
),
"校验日期兑换限制失败"
);
Assert
.
assertEquals
(
exchangeText
,
"
已结束
"
,
"校验马上兑换按钮状态失败"
);
Assert
.
assertEquals
(
exchangeText
,
"
限2019-03-27至2019-03-27日期内兑换
"
,
"校验马上兑换按钮状态失败"
);
logger
.
info
(
"校验实物日期兑换限制已结束成功"
);
logger
.
info
(
"校验实物日期兑换限制已结束成功"
);
break
;
break
;
...
...
src/test/java/http/cases/ExchangeTest/自有_商品兑换限制/自有新卡密_兑换限制测试.java
View file @
aa509f88
...
@@ -3,7 +3,10 @@ package http.cases.ExchangeTest.自有_商品兑换限制;
...
@@ -3,7 +3,10 @@ package http.cases.ExchangeTest.自有_商品兑换限制;
import
http.cases.ExchangeTest.CheckTemplet
;
import
http.cases.ExchangeTest.CheckTemplet
;
import
http.service.Authorization
;
import
http.service.Authorization
;
import
http.service.app.MobileService
;
import
http.service.app.MobileService
;
import
io.restassured.RestAssured
;
import
io.restassured.response.Response
;
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.springframework.beans.factory.annotation.Autowired
;
import
org.testng.Assert
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.BeforeMethod
;
...
@@ -14,6 +17,11 @@ import utils.MatcherString;
...
@@ -14,6 +17,11 @@ import utils.MatcherString;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.sql.SQLException
;
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
* Created by mabo on 2019/3/26
*/
*/
...
@@ -47,6 +55,12 @@ public class 自有新卡密_兑换限制测试 extends CheckTemplet {
...
@@ -47,6 +55,12 @@ public class 自有新卡密_兑换限制测试 extends CheckTemplet {
}
}
// @Test
// public void test(){
//
// Response response = given().get("http://localhost:1112/sql/test");
// response.prettyPrint();
// }
@DataProvider
@DataProvider
public
Object
[][]
providerMethod
(
Method
method
)
{
public
Object
[][]
providerMethod
(
Method
method
)
{
...
...
src/test/java/http/cases/ExchangeTest/自有_商品兑换限制/自有新虚拟商品_充值_兑换限制.java
View file @
aa509f88
...
@@ -317,8 +317,8 @@ public class 自有新虚拟商品_充值_兑换限制 extends CheckTemplet{
...
@@ -317,8 +317,8 @@ public class 自有新虚拟商品_充值_兑换限制 extends CheckTemplet{
case
1
:
case
1
:
// Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验日期兑换限制失败");
// Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验日期兑换限制失败");
Assert
.
assertTrue
(
message
.
contains
(
"限20
19-03-28至2032-04-30
日期内兑换"
),
"校验日期兑换限制失败"
);
Assert
.
assertTrue
(
message
.
contains
(
"限20
30-03-29至2032-04-29
日期内兑换"
),
"校验日期兑换限制失败"
);
Assert
.
assertEquals
(
exchangeText
,
"限20
19-03-28至2032-04-30
日期内兑换"
,
"校验马上兑换按钮状态失败"
);
Assert
.
assertEquals
(
exchangeText
,
"限20
30-03-29至2032-04-29
日期内兑换"
,
"校验马上兑换按钮状态失败"
);
logger
.
info
(
"校验实物日期兑换限制未开始成功"
);
logger
.
info
(
"校验实物日期兑换限制未开始成功"
);
break
;
break
;
...
@@ -331,8 +331,8 @@ public class 自有新虚拟商品_充值_兑换限制 extends CheckTemplet{
...
@@ -331,8 +331,8 @@ public class 自有新虚拟商品_充值_兑换限制 extends CheckTemplet{
case
3
:
case
3
:
// Assert.assertEquals(response.jsonPath().getString("message"),"已结束","校验日期兑换限制失败");
// Assert.assertEquals(response.jsonPath().getString("message"),"已结束","校验日期兑换限制失败");
Assert
.
assertTrue
(
message
.
contains
(
"
已结束
"
),
"校验日期兑换限制失败"
);
Assert
.
assertTrue
(
message
.
contains
(
"
限2019-03-27至2019-03-27日期内兑换
"
),
"校验日期兑换限制失败"
);
Assert
.
assertEquals
(
exchangeText
,
"
已结束
"
,
"校验马上兑换按钮状态失败"
);
Assert
.
assertEquals
(
exchangeText
,
"
限2019-03-27至2019-03-27日期内兑换
"
,
"校验马上兑换按钮状态失败"
);
logger
.
info
(
"校验实物日期兑换限制已结束成功"
);
logger
.
info
(
"校验实物日期兑换限制已结束成功"
);
break
;
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