Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oto
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
龚小红
oto
Commits
f3c67574
Commit
f3c67574
authored
Jul 09, 2021
by
郭姣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
种草相关接口自动化用例
parent
3647d1da
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
263 additions
and
10 deletions
+263
-10
RecommendMaterial.java
src/test/java/com/kjj/cases/assistant/RecommendMaterial.java
+240
-0
BasicConfig.java
src/test/java/com/kjj/config/BasicConfig.java
+8
-0
wechatTestNG.xml
src/test/wechatTestNG.xml
+15
-10
No files found.
src/test/java/com/kjj/cases/assistant/RecommendMaterial.java
0 → 100644
View file @
f3c67574
package
com
.
kjj
.
cases
.
assistant
;
import
static
com
.
kjj
.
config
.
BasicConfig
.*;
import
com.kjj.bean.welfare.Welfare
;
import
com.kjj.cases.admin.Authorization
;
import
com.kjj.utils.BaseUtils
;
import
com.kjj.utils.JsonUtil
;
import
com.kjj.utils.ThreadSleepUtils
;
import
com.kjj.utils.NetworkUtils
;
import
io.restassured.response.Response
;
import
org.testng.Assert
;
import
org.testng.annotations.*
;
import
java.io.IOException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Random
;
public
class
RecommendMaterial
implements
Authorization
{
public
String
sid
;
//加密的销售id
public
String
grasscontentId
;
//文章内容id
public
String
scid
;
//获取文章id
public
String
keyWord
;
//获取猜你想搜的关键字
public
Integer
type
;
//获取赠险类型
public
String
inId
;
//获取赠险详情的id,用于删除赠险
public
String
userId
;
// 代理人用户ID
public
String
visitId
;
// 访问记录ID
@BeforeClass
public
void
setUp
()
{
// 创建用户 并传到network里
AGENT_TKU
=
BaseUtils
.
createTku
();
network
.
agentCookies
.
put
(
"tku"
,
AGENT_TKU
);
//System.out.println("代理人tku:"+AGENT_TKU);
// 获取访客tku
VISITOR_TKU
=
BaseUtils
.
getTku
(
VISITOR_USERID
);
//System.out.println("访客tku:"+VISITOR_TKU);
}
//种草文章列表页
@Test
(
description
=
"代理人_今日早报_种草素材列表页"
,
priority
=
1
)
public
void
代理人
_
今日早报
_
种草素材列表页
()
{
Response
response
=
network
.
getResponse
(
ARTICLE_GETEXPLOSIONCONTENTLIST
);
grasscontentId
=
response
.
jsonPath
().
getString
(
"data[0].contentId"
);
Assert
.
assertNotNull
(
grasscontentId
,
network
.
message
(
ARTICLE_GETEXPLOSIONCONTENTLIST
,
"获取种草素材文章失败"
,
response
.
body
().
asString
()));
}
//种草文章内容页
@Test
(
description
=
"代理人_今日早报_种草素材内容页"
,
priority
=
2
)
public
void
代理人
_
今日早报
_
种草素材内容页
(){
//根据种草素材的ContentId获取Scid
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"contentId"
,
grasscontentId
);
Response
response
=
network
.
getResponse
(
params
,
GETSCID
);
scid
=
response
.
jsonPath
().
getString
(
"data"
);
Assert
.
assertNotNull
(
scid
,
network
.
message
(
params
,
GETSCID
,
"获取文章的scid失败"
,
response
.
body
().
asString
()));
Map
<
String
,
Object
>
infoParams
=
new
HashMap
<
String
,
Object
>();
infoParams
.
put
(
"scid"
,
scid
);
response
=
network
.
getResponse
(
infoParams
,
ARTICLE_H5INFO
);
String
id
=
response
.
jsonPath
().
getString
(
"data.id"
);
Assert
.
assertEquals
(
grasscontentId
,
id
,
network
.
message
(
infoParams
,
ARTICLE_H5INFO
,
"获取种草文章内容失败"
,
response
.
body
().
asString
()));
}
//种草文章转发
@Test
(
description
=
"代理人_今日早报_种草素材转发"
,
priority
=
3
)
public
void
代理人
_
今日早报
_
种草素材转发
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"scId"
,
scid
);
params
.
put
(
"forwardType"
,
1
);
Response
response
=
network
.
getResponse
(
params
,
FORWARD
);
Boolean
success
=
response
.
jsonPath
().
getBoolean
(
"success"
);
Assert
.
assertTrue
(
success
,
network
.
message
(
params
,
FORWARD
,
"种草文章转发失败"
,
response
.
body
().
asString
()));
}
//种草素材标签列表
@Test
(
description
=
"代理人_今日早报_种草素材标签列表"
,
priority
=
4
)
public
void
代理人
_
今日早报
_
种草素材标签列表
(){
Response
response
=
network
.
getResponse
(
GRASS_getTagList
);
String
tagId
=
response
.
jsonPath
().
getString
(
"data[0].id"
);
Assert
.
assertNotNull
(
tagId
,
network
.
message
(
GRASS_getTagList
,
"获取种草素材标签列表失败"
,
response
.
body
().
asString
()));
}
//猜你想搜列表
@Test
(
description
=
"代理人_种草素材_猜你想搜列表"
,
priority
=
5
)
public
void
代理人
_
种草素材
_
猜你想搜列表
(){
Response
response
=
network
.
getResponse
(
GRASS_guessYourMind
);
keyWord
=
response
.
jsonPath
().
getString
(
"data[1].keyWord"
);
Assert
.
assertNotNull
(
keyWord
,
network
.
message
(
GRASS_guessYourMind
,
"获取猜你想搜列表失败"
,
response
.
body
().
asString
()));
}
//搜索获取种草素材列表
@Test
(
description
=
"代理人_种草素材_搜索获取动画种草素材列表"
,
priority
=
6
)
public
void
代理人
_
种草素材
_
搜索获取动画种草素材列表
(){
String
type
=
"game_animation"
;
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"contentType"
,
type
);
params
.
put
(
"pageSize"
,
30
);
params
.
put
(
"keywords"
,
keyWord
);
Response
response
=
network
.
getResponse
(
params
,
GRASS_searchContent
);
ThreadSleepUtils
.
sleep
(
1000
);
String
gameContentId
=
response
.
jsonPath
().
getString
(
"data[0].contentId"
);
Assert
.
assertNotNull
(
gameContentId
,
network
.
message
(
params
,
GRASS_searchContent
,
"获取动画种草素材列表失败"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"代理人_种草素材_搜索获取文章种草素材列表"
,
priority
=
7
)
public
void
代理人
_
种草素材
_
搜索获取文章种草素材列表
(){
String
type
=
"article"
;
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"contentType"
,
type
);
params
.
put
(
"pageSize"
,
30
);
params
.
put
(
"keywords"
,
keyWord
);
Response
response
=
network
.
getResponse
(
params
,
GRASS_searchContent
);
String
gameContentId
=
response
.
jsonPath
().
getString
(
"data[0].contentId"
);
Assert
.
assertNotNull
(
gameContentId
,
network
.
message
(
params
,
GRASS_searchContent
,
"获取文章种草素材列表失败"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"代理人_种草素材_搜索获取视频种草素材列表"
,
priority
=
8
)
public
void
代理人
_
种草素材
_
搜索获取视频种草素材列表
(){
String
type
=
"video"
;
Map
<
String
,
Object
>
params
=
new
HashMap
<
String
,
Object
>();
params
.
put
(
"contentType"
,
type
);
params
.
put
(
"pageSize"
,
30
);
params
.
put
(
"keywords"
,
keyWord
);
Response
response
=
network
.
getResponse
(
params
,
GRASS_searchContent
);
String
gameContentId
=
response
.
jsonPath
().
getString
(
"data[0].contentId"
);
Assert
.
assertNotNull
(
gameContentId
,
network
.
message
(
params
,
GRASS_searchContent
,
"获取文章种草素材列表失败"
,
response
.
body
().
asString
()));
}
//获取赠险列表
@Test
(
description
=
"代理人_赠险管理_获取赠险列表"
,
priority
=
9
)
public
void
代理人
_
赠险管理
_
获取赠险列表
(){
Response
response
=
network
.
getResponse
(
GRASS_insuranceListV3t
);
Object
object
=
response
.
jsonPath
().
getJsonObject
(
"data.insuranceVos"
);
System
.
out
.
println
(
object
);
Assert
.
assertNotNull
(
object
,
network
.
message
(
GRASS_insuranceListV3t
,
"获取赠险列表失败"
,
response
.
body
().
asString
()));
}
//赠险详情
@Test
(
description
=
"代理人_赠险管理_赠险详情"
,
priority
=
10
)
public
void
代理人
_
赠险管理
_
赠险详情
(){
//根据赠险列表接口获取insuranceType
Response
responseParams
=
network
.
getResponse
(
GRASS_insuranceListV3t
);
type
=
responseParams
.
jsonPath
().
getJsonObject
(
"data.insuranceVos[0].insuranceType"
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"insuranceType"
,
type
);
Response
response
=
network
.
getResponse
(
params
,
GRASS_lastInsurance
);
String
desc
=
response
.
jsonPath
().
getString
(
"desc"
);
Assert
.
assertEquals
(
desc
,
"OK"
,
network
.
message
(
params
,
GRASS_lastInsurance
,
"获取赠险详情失败"
,
response
.
body
().
asString
()));
}
// 编辑赠险
@Test
(
description
=
"代理人_赠险管理_新增赠险"
,
priority
=
11
)
public
void
代理人
_
赠险管理
_
新增赠险
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"insuranceTitle"
,
"2222"
);
params
.
put
(
"insuranceType"
,
1
);
params
.
put
(
"insureAmount"
,
1000
);
Response
response
=
network
.
postResponse
(
params
,
GRASS_editInsurance
);
boolean
success
=
response
.
jsonPath
().
getBoolean
(
"success"
);
Assert
.
assertTrue
(
success
,
network
.
message
(
params
,
GRASS_editInsurance
,
"修改赠险信息失败"
,
response
.
body
().
asString
()));
//获取赠险信息
Map
<
String
,
Object
>
responseParams
=
new
HashMap
<>();
responseParams
.
put
(
"insuranceType"
,
1
);
Response
responseAssert
=
network
.
getResponse
(
responseParams
,
GRASS_lastInsurance
);
String
id
=
responseAssert
.
jsonPath
().
getString
(
"data.id"
);
System
.
out
.
println
(
id
);
inId
=
id
;
Assert
.
assertNotNull
(
id
,
network
.
message
(
responseParams
,
GRASS_lastInsurance
,
"修改赠险信息内容失败"
,
responseAssert
.
body
().
asString
()));
}
//删除赠险
@Test
(
description
=
"代理人_赠险管理_删除赠险"
,
priority
=
12
)
public
void
代理人
_
赠险管理
_
删除赠险
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"id"
,
inId
);
Response
response
=
network
.
getResponse
(
params
,
GRASS_delInsurance
);
boolean
success
=
response
.
jsonPath
().
getBoolean
(
"success"
);
boolean
data
=
response
.
jsonPath
().
getBoolean
(
"data"
);
Assert
.
assertTrue
(
success
,
network
.
message
(
params
,
GRASS_delInsurance
,
"删除赠险信息失败"
,
response
.
body
().
asString
()));
Assert
.
assertTrue
(
data
,
network
.
message
(
params
,
GRASS_delInsurance
,
"删除赠险信息校验失败"
,
response
.
body
().
asString
()));
}
//******************** 访客 **********************8
@Test
(
description
=
"访客_记录查看素材"
,
priority
=
13
)
public
void
访客
_
记录查看素材
(){
//tKu 切换为访客
network
.
agentCookies
.
put
(
"tKu"
,
VISITOR_TKU
);
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"scid"
,
scid
);
params
.
put
(
"fromUserId"
,
userId
);
//代理人的用户id
params
.
put
(
"visitPath"
,
1
);
Response
response
=
network
.
getResponse
(
params
,
CONTENT_READ
);
visitId
=
response
.
jsonPath
().
getString
(
"data.visitId"
);
Assert
.
assertNotNull
(
visitId
,
network
.
message
(
params
,
CONTENT_READ
,
"访客记录查看素材失败"
,
response
.
body
().
asString
()));
}
@Test
(
description
=
"访客_文章内容页"
,
priority
=
14
)
public
void
访客
_
文章内容页
(){
Map
<
String
,
Object
>
infoParams
=
new
HashMap
<>();
infoParams
.
put
(
"scid"
,
scid
);
Response
response
=
network
.
getResponse
(
infoParams
,
ARTICLE_H5INFO
);
String
id
=
response
.
jsonPath
().
getString
(
"data.id"
);
Assert
.
assertEquals
(
grasscontentId
,
id
,
network
.
message
(
infoParams
,
ARTICLE_H5INFO
,
"访客查看文章失败"
,
response
.
body
().
asString
()));
}
//是否爆款素材
@Test
(
description
=
"访客_文章类型判断"
,
priority
=
15
)
public
void
访客
_
文章类型判断
(){
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
params
.
put
(
"id"
,
grasscontentId
);
Response
response
=
network
.
getResponse
(
params
,
ARTICLE_GETTAGTYPESBYCONTENTID
);
boolean
isContains
=
response
.
jsonPath
().
getBoolean
(
"data.contains('grass_content')"
);
Assert
.
assertTrue
(
isContains
,
network
.
message
(
params
,
ARTICLE_GETTAGTYPESBYCONTENTID
,
"访客-类型判断错误-类型应该存在种草素材"
,
response
.
body
().
asString
()));
//获得爆款素材详情
Map
<
String
,
Object
>
infoParams
=
new
HashMap
<>();
infoParams
.
put
(
"contentId"
,
grasscontentId
);
response
=
network
.
getResponse
(
infoParams
,
ARTICLE_GETEXPINFO
);
String
tags
=
response
.
jsonPath
().
getString
(
"data.tags"
);
String
recommendReason
=
response
.
jsonPath
().
getString
(
"data.recommendReason"
);
Assert
.
assertNotNull
(
tags
,
network
.
message
(
infoParams
,
ARTICLE_GETEXPINFO
,
"访客-获取文章标签有误"
,
response
.
body
().
asString
()));
Assert
.
assertNotNull
(
recommendReason
,
network
.
message
(
infoParams
,
ARTICLE_GETEXPINFO
,
"访客-获取文章推荐理由有误"
,
response
.
body
().
asString
()));
}
@AfterClass
public
void
tearDown
(){
}
}
src/test/java/com/kjj/config/BasicConfig.java
View file @
f3c67574
...
@@ -597,6 +597,14 @@ public class BasicConfig {
...
@@ -597,6 +597,14 @@ public class BasicConfig {
public
static
final
String
FRIENDS_CHANNELDETAIL
=
HOST
+
"/kjy/mp/materialContent/channelDetail"
;
public
static
final
String
FRIENDS_CHANNELDETAIL
=
HOST
+
"/kjy/mp/materialContent/channelDetail"
;
public
static
final
String
FRIENDS_GETCURRENTINFO
=
HOST
+
"/kjy/mp/timelineContent/getCurrentInfo"
;
public
static
final
String
FRIENDS_GETCURRENTINFO
=
HOST
+
"/kjy/mp/timelineContent/getCurrentInfo"
;
// ************ 种草素材 **************
public
static
final
String
GRASS_getTagList
=
HOST
+
"/kjy/mp/grassContent/getTagList"
;
public
static
final
String
GRASS_guessYourMind
=
HOST
+
"/kjy/mp/timelineContent/guessYourMind"
;
public
static
final
String
GRASS_searchContent
=
HOST
+
"/kjy/mp/grassContent/searchContent"
;
public
static
final
String
GRASS_insuranceListV3t
=
HOST
+
"/kjy/mp/welfare/insuranceListV3"
;
public
static
final
String
GRASS_lastInsurance
=
HOST
+
"/kjy/mp/welfare/lastInsurance"
;
public
static
final
String
GRASS_editInsurance
=
HOST
+
"/kjy/mp/welfare/editInsurance"
;
public
static
final
String
GRASS_delInsurance
=
HOST
+
"/kjy/mp/welfare/delInsurance"
;
// ************** 首页 ****************
// ************** 首页 ****************
...
...
src/test/wechatTestNG.xml
View file @
f3c67574
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite
name=
"集客助手"
verbose=
"1"
thread-count=
"3"
>
<suite
name=
"集客助手"
verbose=
"1"
thread-count=
"3"
>
<!--
<test preserve-order="true" name="首页" >-->
<!--
<test preserve-order="true" name="首页" >-->
<!--
<classes>-->
<!--
<classes>-->
<!--
<class name="com.kjj.qa.cases.Home"/>-->
<!--
<class name="com.kjj.qa.cases.Home"/>-->
<!--
</classes>-->
<!--
</classes>-->
<!--
</test>-->
<!--
</test>-->
<!--
<test preserve-order="true" name="新手任务">-->
<!--
<test preserve-order="true" name="新手任务">-->
<!--
<classes>-->
<!--
<classes>-->
<!--
<class name="com.kjj.qa.cases.Novice"/>-->
<!--
<class name="com.kjj.qa.cases.Novice"/>-->
<!--
</classes>-->
<!--
</classes>-->
<!--
</test>-->
<!--
</test>-->
<test
preserve-order=
"true"
name=
"支付"
>
<test
preserve-order=
"true"
name=
"支付"
>
<classes>
<classes>
<class
name=
"com.kjj.cases.basics.Pay"
/>
<class
name=
"com.kjj.cases.basics.Pay"
/>
...
@@ -51,6 +51,11 @@
...
@@ -51,6 +51,11 @@
<class
name=
"com.kjj.cases.basics.GreetingCard"
/>
<class
name=
"com.kjj.cases.basics.GreetingCard"
/>
</classes>
</classes>
</test>
</test>
<test
preserve-order=
"true"
name =
"种草素材"
>
<classes>
<class
name=
"com.kjj.cases.assistant.RecommendMaterial"
/>
</classes>
</test>
</suite>
</suite>
<!-- Suite -->
<!-- Suite -->
...
...
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