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
b0672e5d
Commit
b0672e5d
authored
Dec 04, 2018
by
马博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
控制互斥功能
parent
14af10f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
4 deletions
+44
-4
Postman.java
src/test/java/base/Postman.java
+12
-3
TestListener.java
src/test/java/base/TestListener.java
+32
-1
No files found.
src/test/java/base/Postman.java
View file @
b0672e5d
...
...
@@ -21,9 +21,11 @@ import static io.restassured.RestAssured.given;
* Created by hanzhanli on 2017/11/9.
*/
public
class
Postman
{
static
String
dingdingUrl
=
"https://shark.dui88.com/test/integration"
;
static
String
testPlatformUrl
=
"http://101.37.27.82:8080/insert"
;
static
String
miriaUrl
=
"http://miria-aliyun.duibatest.com.cn/autoTest/finish"
;
final
static
String
dingdingUrl
=
"https://shark.dui88.com/test/integration"
;
final
static
String
testPlatformUrl
=
"http://101.37.27.82:8080/insert"
;
final
static
String
miriaUrl
=
"http://miria-aliyun.duibatest.com.cn/autoTest/finish"
;
final
static
String
miriaUrlTesting
=
"http://miria-aliyun.duibatest.com.cn/autoTest/testing"
;
//dingdingUrl="http://www.json.cn/";
private
static
Logger
logger
=
LogManager
.
getLogger
(
Postman
.
class
);
public
static
void
send2Dingding
(
Map
result
){
...
...
@@ -58,6 +60,13 @@ public class Postman {
System
.
out
.
println
(
"miriaUrl:"
+
miriaUrl
);
System
.
out
.
println
(
"miria响应结果:"
+
response
.
asString
());
}
public
static
void
sendTesting
(
Map
result
){
Response
response
=
given
().
params
(
result
).
get
(
miriaUrl
);
System
.
out
.
println
(
"jobName:"
+
result
.
get
(
"jobName"
));
System
.
out
.
println
(
"miriaUrl:"
+
miriaUrlTesting
);
System
.
out
.
println
(
"miria响应结果:"
+
response
.
asString
());
}
public
static
Boolean
getName
(){
Calendar
c
=
Calendar
.
getInstance
();
Date
date
=
new
Date
();
...
...
src/test/java/base/TestListener.java
View file @
b0672e5d
package
base
;
import
java.io.UnsupportedEncodingException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.core.env.Environment
;
import
org.testng.*
;
/**
...
...
@@ -12,6 +18,12 @@ import org.testng.*;
public
class
TestListener
implements
ITestListener
{
public
DuibaLog
logger
=
DuibaLog
.
getLogger
();
String
run
=
System
.
getProperty
(
"run"
);
ApplicationContext
context
=
new
AnnotationConfigApplicationContext
(
Config
.
class
);
Environment
env
=
context
.
getBean
(
Environment
.
class
);
public
TestListener
()
throws
UnsupportedEncodingException
{
}
public
void
onFinish
(
ITestContext
context
)
{
Iterator
<
ITestResult
>
listOfFailedTests
=
context
.
getFailedTests
().
getAllResults
().
iterator
();
while
(
listOfFailedTests
.
hasNext
())
{
...
...
@@ -65,16 +77,26 @@ public class TestListener implements ITestListener {
// TODO Auto-generated method stub
logger
.
info
(
"onStart~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
);
//服务检查
boolean
ServiceDoctor
=
Boolean
.
parseBoolean
(
System
.
getProperty
(
"ServiceDoctor"
));
if
(
ServiceDoctor
){
try
{
serviceDoctor
();
}
catch
(
SkipException
e
){
SFExpress
.
skip
=
context
.
getAllTestMethods
().
length
;
// throw e;
}
}
//运行开始,触发互斥功能,用于定时任务
Map
<
String
,
String
>
mapJob
=
new
HashMap
<>();
try
{
mapJob
.
put
(
"jobName"
,
getJob
());
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
Postman
.
sendTesting
(
mapJob
);
}
public
void
serviceDoctor
(){
logger
.
info
(
"duiba-server开始检测"
);
...
...
@@ -107,4 +129,13 @@ public class TestListener implements ITestListener {
res
=
simpleDateFormat
.
format
(
date
);
return
res
;
}
public
String
getJob
()
throws
UnsupportedEncodingException
{
return
getByRun
(
run
,
"job"
);
}
public
String
getByRun
(
String
run
,
String
type
)
throws
UnsupportedEncodingException
{
run
=
run
.
substring
(
run
.
indexOf
(
"_"
)+
1
,
run
.
indexOf
(
"."
));
run
=
this
.
env
.
getProperty
(
run
+
"."
+
type
);
return
new
String
(
run
.
getBytes
(
"ISO-8859-1"
),
"UTF-8"
);
//ISO-8859-1
}
}
\ No newline at end of file
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