Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nwn_Api_auto_test
Overview
Overview
Details
Activity
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
shuai
nwn_Api_auto_test
Commits
0b638d56
Commit
0b638d56
authored
Dec 21, 2018
by
Li Yongyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增验收码等接口用例
parent
b990f5fe
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
165 additions
and
149 deletions
+165
-149
CaseMake.xls
nwn_Api_auto_test/TestData/CaseMake.xls
+0
-0
DataAll.xls
nwn_Api_auto_test/TestData/DataAll.xls
+0
-0
DefectTest.xml
nwn_Api_auto_test/src/DefectTest.xml
+1
-1
addAccount.java
nwn_Api_auto_test/src/com/offcn/api/nwn/addAccount.java
+1
-1
addChildTier.java
nwn_Api_auto_test/src/com/offcn/api/nwn/addChildTier.java
+2
-2
NWN.java
nwn_Api_auto_test/src/com/offcn/process/NWN.java
+21
-1
APITest_nwn.java
nwn_Api_auto_test/src/com/offcn/test/APITest_nwn.java
+139
-143
MakeTestCases.java
nwn_Api_auto_test/src/makeTestCase/MakeTestCases.java
+1
-1
No files found.
nwn_Api_auto_test/TestData/CaseMake.xls
View file @
0b638d56
No preview for this file type
nwn_Api_auto_test/TestData/DataAll.xls
View file @
0b638d56
No preview for this file type
nwn_Api_auto_test/src/DefectTest.xml
View file @
0b638d56
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<classes>
<classes>
<class
name=
"com.puhui.test.RenMai_APITest"
>
<class
name=
"com.puhui.test.RenMai_APITest"
>
<methods>
<methods>
<include
name=
"f"
invocation-numbers=
""
/>
<include
name=
"f"
invocation-numbers=
"
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
"
/>
</methods>
</methods>
</class>
</class>
</classes>
</classes>
...
...
nwn_Api_auto_test/src/com/offcn/api/nwn/addAccount.java
View file @
0b638d56
...
@@ -99,7 +99,7 @@ public class addAccount extends NWN implements API {
...
@@ -99,7 +99,7 @@ public class addAccount extends NWN implements API {
result
=
result
&&
false
;
result
=
result
&&
false
;
failReason
=
failReason
+
"code is expected "
failReason
=
failReason
+
"code is expected "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
+
jp
.
getString
(
"
ret
code"
)
+
"."
;
}
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
...
...
nwn_Api_auto_test/src/com/offcn/api/nwn/addChildTier.java
View file @
0b638d56
...
@@ -94,7 +94,7 @@ public class addChildTier extends NWN implements API {
...
@@ -94,7 +94,7 @@ public class addChildTier extends NWN implements API {
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
data
.
get
(
"statusCode"
).
toString
()
+
" but actually "
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
+
String
.
valueOf
(
re
.
getStatusCode
())
+
". "
;
}
}
if
(
json
.
length
()
!=
0
)
{
if
(
json
.
length
()
!=
0
)
{
String
msg
=
jp
.
getString
(
"message"
);
String
msg
=
jp
.
getString
(
"message"
);
...
@@ -106,7 +106,7 @@ public class addChildTier extends NWN implements API {
...
@@ -106,7 +106,7 @@ public class addChildTier extends NWN implements API {
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
data
.
get
(
"code"
).
toString
()
+
" but actually "
+
jp
.
getString
(
"code"
)
+
"."
;
+
jp
.
getString
(
"code"
)
+
"."
;
}
}
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
if
((
data
.
get
(
"msg"
)
!=
null
)
&&
(
msg
!=
null
)
&&
(!
msg
.
equals
(
data
.
get
(
"msg"
).
toString
())))
{
result
=
result
&&
false
;
result
=
result
&&
false
;
failReason
=
failReason
+
"msg is expected "
failReason
=
failReason
+
"msg is expected "
...
...
nwn_Api_auto_test/src/com/offcn/process/NWN.java
View file @
0b638d56
...
@@ -40,6 +40,8 @@ public class NWN extends BasicsGM{
...
@@ -40,6 +40,8 @@ public class NWN extends BasicsGM{
public
static
List
<
String
>
n_admin_id_List
=
new
ArrayList
<
String
>();
//n_admin的id
public
static
List
<
String
>
n_admin_id_List
=
new
ArrayList
<
String
>();
//n_admin的id
public
static
List
<
String
>
n_admin_phone_List
=
new
ArrayList
<
String
>();
//n_admin的phone
public
static
List
<
String
>
n_admin_phone_List
=
new
ArrayList
<
String
>();
//n_admin的phone
public
static
List
<
String
>
n_admin_username_List
=
new
ArrayList
<
String
>();
//n_admin的username
public
static
List
<
String
>
n_admin_username_List
=
new
ArrayList
<
String
>();
//n_admin的username
public
static
List
<
String
>
getcode_id_List
=
new
ArrayList
<
String
>();
//getcode的id
public
static
List
<
String
>
n_getcode_id_List
=
new
ArrayList
<
String
>();
//getcode的id
public
static
String
level_id_List
=
""
;
//层级的id
public
static
String
level_id_List
=
""
;
//层级的id
public
static
List
<
String
>
user_id_List
=
new
ArrayList
<
String
>();
//user_id
public
static
List
<
String
>
user_id_List
=
new
ArrayList
<
String
>();
//user_id
...
@@ -127,6 +129,8 @@ public class NWN extends BasicsGM{
...
@@ -127,6 +129,8 @@ public class NWN extends BasicsGM{
for
(
int
i
=
0
;
i
<
n_package_idList
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
n_package_idList
.
size
();
i
++){
try
{
try
{
deleteFromDB
(
"n_package"
,
"id"
,
n_package_idList
.
get
(
i
));
deleteFromDB
(
"n_package"
,
"id"
,
n_package_idList
.
get
(
i
));
//deleteFromDB("n_packcode", "package_id", n_package_idList.get(i));
//deleteFromDB("n_packcode_record", "package_id", n_package_idList.get(i));
user_List
.
add
(
n_package_idList
.
get
(
i
));
user_List
.
add
(
n_package_idList
.
get
(
i
));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -154,7 +158,23 @@ public class NWN extends BasicsGM{
...
@@ -154,7 +158,23 @@ public class NWN extends BasicsGM{
user_id_List
.
removeAll
(
user_List
);
user_id_List
.
removeAll
(
user_List
);
// System.out.println(user_idList.toString());
// System.out.println(user_idList.toString());
}
}
//清除getcode_id_List
public
void
cleann_getcode_id_List_FromDB
()
{
List
<
String
>
user_List
=
new
ArrayList
<
String
>();
for
(
int
i
=
0
;
i
<
getcode_id_List
.
size
();
i
++){
try
{
deleteFromDB
(
"n_packcode"
,
"package_id"
,
getcode_id_List
.
get
(
i
));
deleteFromDB
(
"n_packcode_record"
,
"package_id"
,
getcode_id_List
.
get
(
i
));
user_List
.
add
(
getcode_id_List
.
get
(
i
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
Log
.
logInfo
(
"清除数据失败getcode_id_List"
);
}
}
getcode_id_List
.
removeAll
(
user_List
);
// System.out.println(user_idList.toString());
}
//
//
//
//
...
...
nwn_Api_auto_test/src/com/offcn/test/APITest_nwn.java
View file @
0b638d56
package
com
.
offcn
.
test
;
package
com
.
offcn
.
test
;
import
io.restassured.response.Response
;
import
io.restassured.response.Response
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
java.sql.SQLException
;
import
net.sf.json.JSONObject
;
import
java.util.HashMap
;
import
org.testng.Assert
;
import
org.testng.annotations.AfterClass
;
import
net.sf.json.JSONObject
;
import
com.offcn.TestData.offcn_api_testData
;
import
com.offcn.TestUnti.Log
;
import
org.testng.Assert
;
import
com.offcn.TestUnti.Mail
;
import
org.testng.annotations.AfterClass
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.OAuthTokenUnti
;
import
com.offcn.TestData.offcn_api_testData
;
import
com.offcn.TestUnti.ReadProperties
;
import
com.offcn.TestUnti.Log
;
import
com.offcn.TestUnti.Reflect_api
;
import
com.offcn.TestUnti.Mail
;
import
com.offcn.TestUnti.SheetUtils
;
import
com.offcn.TestUnti.MapUtil
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.TestUnti.OAuthTokenUnti
;
import
com.offcn.TestUnti.XMLread
;
import
com.offcn.TestUnti.ReadProperties
;
import
com.offcn.interfaces.API
;
import
com.offcn.TestUnti.Reflect_api
;
import
com.offcn.listener.ProcessTestng
;
import
com.offcn.TestUnti.SheetUtils
;
import
com.offcn.listener.ResultTestng
;
import
com.offcn.TestUnti.StringUtils
;
import
com.offcn.process.BasicsGM
;
import
com.offcn.TestUnti.XMLread
;
import
com.offcn.process.NWN
;
import
com.offcn.interfaces.API
;
import
com.offcn.process.TK
;
import
com.offcn.listener.ProcessTestng
;
import
com.offcn.process.XYZB
;
import
com.offcn.listener.ResultTestng
;
import
com.offcn.process.BasicsGM
;
import
org.testng.annotations.Listeners
;
import
com.offcn.process.NWN
;
import
org.testng.annotations.Test
;
import
com.offcn.process.TK
;
import
com.offcn.process.XYZB
;
@Listeners
({
ProcessTestng
.
class
,
ResultTestng
.
class
})
public
class
APITest_nwn
extends
NWN
{
import
org.testng.annotations.Listeners
;
import
org.testng.annotations.Test
;
@Test
(
dataProvider
=
"renmai"
,
dataProviderClass
=
offcn_api_testData
.
class
)
public
void
f
(
HashMap
<
String
,
Object
>
data
)
{
@Listeners
({
ProcessTestng
.
class
,
ResultTestng
.
class
})
public
class
APITest_nwn
extends
NWN
{
Log
.
logInfo
(
data
.
get
(
"TCNO"
).
toString
()
+
" Step "
+
data
.
get
(
"Description"
).
toString
()
+
" is running......"
);
@Test
(
dataProvider
=
"renmai"
,
dataProviderClass
=
offcn_api_testData
.
class
)
API
obj
=
new
Reflect_api
().
Reflections
(
data
);
public
void
f
(
HashMap
<
String
,
Object
>
data
)
{
BasicsGM
.
map
=
new
XMLread
().
getSystem
();
Log
.
logInfo
(
data
.
get
(
"TCNO"
).
toString
()
+
" Step "
+
data
.
get
(
"Description"
).
toString
()
+
" is running......"
);
obj
.
initialize
(
data
);
API
obj
=
new
Reflect_api
().
Reflections
(
data
);
data
=
obj
.
handleInput
(
data
);
BasicsGM
.
map
=
new
XMLread
().
getSystem
();
String
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
obj
.
initialize
(
data
);
Long
startTime
=
System
.
currentTimeMillis
();
Response
re
=
obj
.
SendRequest
(
data
,
data
.
get
(
"serviceUrl"
).
toString
(),
data
.
get
(
"Request"
).
toString
());
data
=
obj
.
handleInput
(
data
);
Long
endTime
=
System
.
currentTimeMillis
();
String
parameter
=
MapUtil
.
getValue
(
"parameter"
,
data
);
String
time
=(
endTime
-
startTime
)+
"毫秒"
;
Long
startTime
=
System
.
currentTimeMillis
();
Response
re
=
obj
.
SendRequest
(
data
,
data
.
get
(
"serviceUrl"
).
toString
(),
data
.
get
(
"Request"
).
toString
());
String
codeORerrcode
=
""
;
Long
endTime
=
System
.
currentTimeMillis
();
String
msgORerrmsy
=
""
;
String
result
=
""
;
String
time
=(
endTime
-
startTime
)+
"毫秒"
;
String
body
=
""
;
String
codeORerrcode
=
""
;
if
(
re
!=
null
){
String
msgORerrmsy
=
""
;
String
result
=
""
;
body
=
re
.
asString
();
String
body
=
""
;
if
(
body
.
contains
(
"<title>"
)){
int
Alength
=
"<title>"
.
length
();
if
(
re
!=
null
){
int
start
=
body
.
indexOf
(
"<title>"
);
int
end
=
body
.
indexOf
(
"</title>"
)+
1
;
body
=
re
.
asString
();
body
=
"页面标题:"
+
body
.
substring
(
start
+
Alength
,
end
-
1
);
if
(
body
.
contains
(
"<title>"
)){
result
=
body
;
int
Alength
=
"<title>"
.
length
();
if
(
data
.
get
(
"Description"
).
toString
().
contains
(
"流程"
)){
int
start
=
body
.
indexOf
(
"<title>"
);
result
=
obj
.
handleOutput
(
re
,
data
);
int
end
=
body
.
indexOf
(
"</title>"
)+
1
;
}
body
=
"页面标题:"
+
body
.
substring
(
start
+
Alength
,
end
-
1
);
}
else
if
(
body
.
contains
(
"<html>"
)){
result
=
body
;
body
=
"返回html页面,状态码:"
+
re
.
getStatusCode
();
if
(
data
.
get
(
"Description"
).
toString
().
contains
(
"流程"
)){
if
(
data
.
get
(
"Description"
).
toString
().
contains
(
"流程"
)){
result
=
obj
.
handleOutput
(
re
,
data
);
result
=
obj
.
handleOutput
(
re
,
data
);
}
}
}
else
if
(
body
.
contains
(
"<html>"
)){
}
else
{
body
=
"返回html页面,状态码:"
+
re
.
getStatusCode
();
result
=
obj
.
handleOutput
(
re
,
data
);
if
(
data
.
get
(
"Description"
).
toString
().
contains
(
"流程"
)){
}
result
=
obj
.
handleOutput
(
re
,
data
);
codeORerrcode
=
getCode
(
re
);
}
msgORerrmsy
=
getMsg
(
re
);
}
else
{
result
=
obj
.
handleOutput
(
re
,
data
);
}
}
codeORerrcode
=
getCode
(
re
);
Log
.
logInfo
(
"返回结果="
+
StringUtils
.
decodeUnicode
(
body
));
msgORerrmsy
=
getMsg
(
re
);
System
.
out
.
println
();
}
//数据回写
Log
.
logInfo
(
"返回结果="
+
StringUtils
.
decodeUnicode
(
body
));
//// HashMap<String, Object> ExpectResult=MapUtil.Expect(data);
System
.
out
.
println
();
// SheetUtils sheet = new SheetUtils("DataAll.xls", "Output");
// sheet.writeExcel(
// data.get("NO").toString(),
//数据回写
// data.get("TCNO").toString() + "_Step" + data.get("Step").toString(),
//// HashMap<String, Object> ExpectResult=MapUtil.Expect(data);
// data.get("Description").toString(),
// SheetUtils sheet = new SheetUtils("DataAll.xls", "Output");
// parameter,
// sheet.writeExcel(
//// JSONObject.fromObject(ExpectResult).toString(),
// data.get("NO").toString(),
// re.getStatusCode()+"",
// data.get("TCNO").toString() + "_Step" + data.get("Step").toString(),
//// StringUtils.decodeUnicode(re==null?"":re.asString()),
// data.get("Description").toString(),
// StringUtils.decodeUnicode(body),
// parameter,
// codeORerrcode,
//// JSONObject.fromObject(ExpectResult).toString(),
// msgORerrmsy,
// re.getStatusCode()+"",
// result,
//// StringUtils.decodeUnicode(re==null?"":re.asString()),
// time
// StringUtils.decodeUnicode(body),
// );
// codeORerrcode,
// msgORerrmsy,
if
(
result
.
indexOf
(
"Fail"
)!=-
1
){
// result,
String
Expect1
=
data
.
get
(
"code"
)==
null
?
""
:
data
.
get
(
"code"
).
toString
();
// time
String
Expect2
=
data
.
get
(
"msg"
)==
null
?
""
:
data
.
get
(
"msg"
).
toString
();
// );
String
Expect3
=
data
.
get
(
"custom"
)==
null
?
""
:
data
.
get
(
"custom"
).
toString
();
if
(
body
.
contains
(
"HTML"
)){
if
(
result
.
indexOf
(
"Fail"
)!=-
1
){
body
=
"异常页面信息"
;
String
Expect1
=
data
.
get
(
"code"
)==
null
?
""
:
data
.
get
(
"code"
).
toString
();
}
String
Expect2
=
data
.
get
(
"msg"
)==
null
?
""
:
data
.
get
(
"msg"
).
toString
();
Assert
.
assertEquals
(
StringUtils
.
decodeUnicode
(
body
),
Expect1
+
","
+
Expect2
+
","
+
Expect3
);
String
Expect3
=
data
.
get
(
"custom"
)==
null
?
""
:
data
.
get
(
"custom"
).
toString
();
}
else
{
if
(
body
.
contains
(
"HTML"
)){
Assert
.
assertTrue
(
true
);
body
=
"异常页面信息"
;
}
}
}
Assert
.
assertEquals
(
StringUtils
.
decodeUnicode
(
body
),
Expect1
+
","
+
Expect2
+
","
+
Expect3
);
}
else
{
@AfterClass
Assert
.
assertTrue
(
true
);
public
void
afterClass
()
{
}
//测试结束删除测试所用的数据
}
if
(!
isClearMysql
)
{
this
.
cleann_n_admin_card_no_List_FromDB
();
@AfterClass
this
.
cleann_n_package_List_FromDB
();
public
void
afterClass
()
{
this
.
cleann_user_id_List_FromDB
();
//测试结束删除测试所用的数据
this
.
cleann_getcode_id_List_FromDB
();
if
(!
isClearMysql
)
{
try
{
this
.
cleann_n_admin_card_no_List_FromDB
();
if
(
stmt
!=
null
){
this
.
cleann_n_package_List_FromDB
();
stmt
.
close
();
this
.
cleann_user_id_List_FromDB
();
}
try
{
if
(
conn
!=
null
){
if
(
stmt
!=
null
){
conn
.
close
();
stmt
.
close
();
}
}
}
catch
(
SQLException
e
)
{
if
(
conn
!=
null
){
e
.
printStackTrace
();
conn
.
close
();
}
}
}
}
catch
(
SQLException
e
)
{
Log
.
logInfo
(
"========测试结束========"
);
e
.
printStackTrace
();
}
}
}
Log
.
logInfo
(
"========测试结束========"
);
}
}
}
nwn_Api_auto_test/src/makeTestCase/MakeTestCases.java
View file @
0b638d56
...
@@ -91,7 +91,7 @@ public class MakeTestCases {
...
@@ -91,7 +91,7 @@ public class MakeTestCases {
//数据回写
//数据回写
SheetUtils
sheet
=
new
SheetUtils
(
wenjianming
,
Sheet
);
SheetUtils
sheet
=
new
SheetUtils
(
wenjianming
,
Sheet
);
sheet
.
writeExcel
(
sheet
.
writeExcel
(
// s,
(
i
+
1
)+
""
,
(
i
+
1
)+
""
,
leiming
+
"_"
+
(
i
+
1
),
leiming
+
"_"
+
(
i
+
1
),
(
i
+
1
)+
""
,
(
i
+
1
)+
""
,
...
...
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