Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
ManningTest
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ManningTest
ManningTest
Commits
ed8c9afd
Commit
ed8c9afd
authored
Jun 08, 2022
by
xiongjunyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化脚本执行代码
parent
a7f923ce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
313 additions
and
16 deletions
+313
-16
.gitignore
.gitignore
+7
-0
.gitignore
.idea/.gitignore
+2
-1
MyAppLog.log
MyAppLog.log
+193
-0
pom.xml
pom.xml
+4
-4
ScriptUtil.java
...main/java/com/miya/manning/framework/util/ScriptUtil.java
+19
-8
Express.java
src/main/java/com/miya/manning/test/flow/order/Express.java
+7
-2
Mainprocess.java
...in/java/com/miya/manning/test/flow/order/Mainprocess.java
+3
-1
Condition.java
src/main/java/com/miya/manning/vo/Condition.java
+51
-0
ExcuteableCondition.java
src/main/java/com/miya/manning/vo/ExcuteableCondition.java
+5
-0
ApplicationContext.xml
src/main/resources/ApplicationContext.xml
+22
-0
Express.xls
src/main/resources/testcase/Express.xls
+0
-0
Script.xls
src/main/resources/testcase/Scripts/Script.xls
+0
-0
No files found.
.gitignore
0 → 100644
View file @
ed8c9afd
# Default ignored files
/shelf/
/workspace.xml
target/
*.iml
.idea/
**/*.log
.idea/.gitignore
View file @
ed8c9afd
...
...
@@ -3,4 +3,5 @@
/workspace.xml
target/
*.iml
.idea/
\ No newline at end of file
.idea/
**/*.log
MyAppLog.log
View file @
ed8c9afd
This diff is collapsed.
Click to expand it.
pom.xml
View file @
ed8c9afd
...
...
@@ -146,7 +146,7 @@
<version>
2.6
</version>
</dependency>
<!-- allure测试报表 -->
<dependency>
<
!--<
dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-testng-adaptor</artifactId>
<version>1.3.6</version>
...
...
@@ -156,18 +156,18 @@
<artifactId>testng</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependency>
-->
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-nop
</artifactId>
<version>
1.7.6
</version>
</dependency>
<dependency>
<
!--<
dependency>
<groupId>io.qameta.allure</groupId>
<artifactId>allure-testng</artifactId>
<version>2.12.1</version>
<scope>test</scope>
</dependency>
</dependency>
-->
<dependency>
<groupId>
org.testng
</groupId>
<artifactId>
testng
</artifactId>
...
...
src/main/java/com/miya/manning/framework/util/ScriptUtil.java
View file @
ed8c9afd
...
...
@@ -13,18 +13,29 @@ import java.util.stream.Collectors;
public
class
ScriptUtil
{
private
static
final
Logger
log
=
Logger
.
getLogger
(
ScriptUtil
.
class
);
public
static
void
ExcuteScript
(
List
<
Script
>
scriptList
,
TestCase
testCase
)
throws
Exception
{
public
static
void
ExcuteScript
(
List
<
Script
>
execScriptList
)
throws
Exception
{
ExcuteableScript
script
=
null
;
ApplicationContext
ac
=
new
ClassPathXmlApplicationContext
(
"ApplicationContext.xml"
);
ScriptFactory
scriptFactory
=
(
ScriptFactory
)
ac
.
getBean
(
"ScriptFactory"
);
List
<
Script
>
list_script
=
scriptList
.
stream
().
filter
(
x
->
x
.
getScript_name
().
equals
(
testCase
.
getScript_name
())).
collect
(
Collectors
.
toList
());
if
(
list_scrip
t
.
size
()
==
0
)
{
//
ScriptFactory scriptFactory = (ScriptFactory) ac.getBean("ScriptFactory");
//
List<Script> list_script =scriptList.stream().filter(x -> x.getScript_name().equals(testCase.getScript_name())).collect(Collectors.toList());
if
(
execScriptLis
t
.
size
()
==
0
)
{
throw
new
Exception
(
"没有匹配到脚本!"
);
}
if
(
list_scrip
t
.
size
()
>
1
){
}
if
(
execScriptLis
t
.
size
()
>
1
){
throw
new
Exception
(
"匹配到多个同名脚本!"
);
}
else
{
Class
<?>
clz
=
Class
.
forName
(
"com.miya.manning.vo.ScriptFactory"
);
Script
sc
=
list_script
.
get
(
0
);
Script
sc
=
execScriptList
.
get
(
0
);
if
(
ScriptType
.
JAVA_SCRIPT
.
getType
().
equals
(
sc
.
getSrcipt_type
())){
JavaScript
javaScript
=
(
JavaScript
)
ac
.
getBean
(
"javaScript"
);
log
.
info
(
"开始执行脚本:"
+
sc
.
getScript_name
());
javaScript
.
excute
(
sc
.
getScript_param
());
}
if
(
ScriptType
.
SSH_SCRIPT
.
getType
().
equals
(
sc
.
getSrcipt_type
())){
SSHScript
sshScript
=
(
SSHScript
)
ac
.
getBean
(
"sshScript"
);
log
.
info
(
"开始执行脚本:"
+
sc
.
getScript_name
());
sshScript
.
excute
(
sc
.
getScript_param
());
}
/*Class<?> clz = Class.forName("com.miya.manning.vo.ScriptFactory");
Script sc = execScriptList.get(0);
Method method = clz.getDeclaredMethod("create" + sc.getSrcipt_type() + "Script",String.class);
if(ScriptType.JAVA_SCRIPT.getType().equals(sc.getSrcipt_type())){
script = (JavaScript) method.invoke(scriptFactory,sc.getScript_param());
...
...
@@ -35,7 +46,7 @@ public class ScriptUtil {
script = (SSHScript) method.invoke(scriptFactory,sc.getScript_param());
log.info("开始执行脚本:" + sc.getScript_name());
script.excute(sc.getScript_param());
}
}
*/
}
}
...
...
src/main/java/com/miya/manning/test/flow/order/Express.java
View file @
ed8c9afd
...
...
@@ -12,6 +12,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
java.util.stream.Collectors
;
/**
* @ProjectName: manning_test
...
...
@@ -33,7 +34,7 @@ public class Express {
private
String
url_start
=
"https://cs2-uat.mannings.com.cn/"
;
private
String
script_path
=
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"target"
+
File
.
separator
+
"classes"
+
File
.
separator
+
"testcase"
+
File
.
separator
+
"Scripts"
+
File
.
separator
+
"Script.xls"
;
private
String
path
=
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"target"
+
File
.
separator
+
"classes"
+
File
.
separator
+
"testcase"
+
File
.
separator
+
"
Delivery
.xls"
;
private
String
path
=
System
.
getProperty
(
"user.dir"
)
+
File
.
separator
+
"target"
+
File
.
separator
+
"classes"
+
File
.
separator
+
"testcase"
+
File
.
separator
+
"
Express
.xls"
;
//private String path = "D:\\autotest\\test_liucheng\\test_liucheng\\huihua_saas1.xls";
private
Map
<
String
,
String
>
res_map
=
new
TreeMap
<>();
private
static
Map
<
String
,
Integer
>
int_var_map
=
new
HashMap
<>();
...
...
@@ -77,7 +78,8 @@ public class Express {
public
void
Express
(
TestCase
testCase
)
throws
Exception
{
String
script_name
=
testCase
.
getScript_name
();
if
(!
script_name
.
isEmpty
()){
ScriptUtil
.
ExcuteScript
(
Scripts
,
testCase
);
List
<
Script
>
execScriptList
=
Scripts
.
stream
().
filter
(
x
->
x
.
getScript_name
().
equals
(
testCase
.
getScript_name
())).
collect
(
Collectors
.
toList
());
ScriptUtil
.
ExcuteScript
(
execScriptList
);
}
String
pre_sql
=
testCase
.
getPre_sql
();
String
databasename
=
testCase
.
getDatabasename
();
...
...
@@ -156,4 +158,7 @@ public class Express {
Assert.assertEquals(response.getData(), data);
}*/
}
}
src/main/java/com/miya/manning/test/flow/order/Mainprocess.java
View file @
ed8c9afd
...
...
@@ -13,6 +13,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
java.util.stream.Collectors
;
/**
* @ProjectName: manning_test
...
...
@@ -78,7 +79,8 @@ public class Mainprocess {
public
void
Mainprocess
(
TestCase
testCase
)
throws
Exception
{
String
script_name
=
testCase
.
getScript_name
();
if
(!
script_name
.
isEmpty
()){
ScriptUtil
.
ExcuteScript
(
Scripts
,
testCase
);
List
<
Script
>
execScriptList
=
Scripts
.
stream
().
filter
(
x
->
x
.
getScript_name
().
equals
(
testCase
.
getScript_name
())).
collect
(
Collectors
.
toList
());
ScriptUtil
.
ExcuteScript
(
execScriptList
);
}
String
pre_sql
=
testCase
.
getPre_sql
();
String
databasename
=
testCase
.
getDatabasename
();
...
...
src/main/java/com/miya/manning/vo/Condition.java
0 → 100644
View file @
ed8c9afd
package
com
.
miya
.
manning
.
vo
;
public
class
Condition
{
private
String
condition_name
;
private
String
condition_type
;
private
String
condition_param
;
private
String
condition_usage
;
public
String
getCondition_name
()
{
return
condition_name
;
}
public
void
setCondition_name
(
String
condition_name
)
{
this
.
condition_name
=
condition_name
;
}
public
String
getCondition_type
()
{
return
condition_type
;
}
public
void
setCondition_type
(
String
condition_type
)
{
this
.
condition_type
=
condition_type
;
}
public
String
getCondition_param
()
{
return
condition_param
;
}
public
void
setCondition_param
(
String
condition_param
)
{
this
.
condition_param
=
condition_param
;
}
public
String
getCondition_usage
()
{
return
condition_usage
;
}
public
void
setCondition_usage
(
String
condition_usage
)
{
this
.
condition_usage
=
condition_usage
;
}
@Override
public
String
toString
()
{
return
"Condition{"
+
"condition_name='"
+
condition_name
+
'\''
+
", condition_type='"
+
condition_type
+
'\''
+
", condition_param='"
+
condition_param
+
'\''
+
", condition_usage='"
+
condition_usage
+
'\''
+
'}'
;
}
}
src/main/java/com/miya/manning/vo/ExcuteableCondition.java
0 → 100644
View file @
ed8c9afd
package
com
.
miya
.
manning
.
vo
;
public
interface
ExcuteableCondition
{
void
excute
(
TestCase
testcase
,
boolean
flag
,
int
times
);
}
src/main/resources/ApplicationContext.xml
0 → 100644
View file @
ed8c9afd
<?xml version="1.0" encoding="UTF-8" ?>
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop=
"http://www.springframework.org/schema/aop"
xmlns:tx=
"http://www.springframework.org/schema/tx"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop
https://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd"
xmlns:context=
"http://www.springframework.org/schema/context"
>
<context:component-scan
base-package=
"com.miya.manning.vo"
/>
<context:property-placeholder
location=
"classpath:db.properties"
/>
<aop:aspectj-autoproxy/>
<bean
id=
"javaScript"
class=
"com.miya.manning.vo.JavaScript"
>
</bean>
<bean
id=
"sshScript"
class=
"com.miya.manning.vo.SSHScript"
>
</bean>
</beans>
\ No newline at end of file
src/main/resources/testcase/Express.xls
View file @
ed8c9afd
No preview for this file type
src/main/resources/testcase/Scripts/Script.xls
View file @
ed8c9afd
No preview for this file type
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