Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
auto-test
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
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
xie.qin
auto-test
Commits
d88f2d46
Commit
d88f2d46
authored
Jul 20, 2021
by
xie.qin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixed to support sanity test stably.
parent
a0dc9565
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
32 additions
and
17 deletions
+32
-17
README.md
README.md
+15
-9
sanity_test.png
gallery/sanity_test.png
+0
-0
OpenApiParser.java
...main/java/com/fuzamei/autotest/openapi/OpenApiParser.java
+0
-0
RestfulMessageEntity.java
...va/com/fuzamei/autotest/openapi/RestfulMessageEntity.java
+5
-0
RestfulMessageEventListener.java
...fuzamei/autotest/openapi/RestfulMessageEventListener.java
+0
-0
BackendServiceProperties.java
...fuzamei/autotest/properties/BackendServiceProperties.java
+1
-0
application.properties
src/main/resources/application.properties
+8
-5
logback-spring.xml
src/main/resources/logback-spring.xml
+0
-0
ApiVerification.java
...a/com/fuzamei/autotest/steps/openapi/ApiVerification.java
+1
-1
backend.feature
src/test/resources/features/sanitytest/backend.feature
+2
-2
No files found.
README.md
View file @
d88f2d46
...
...
@@ -22,11 +22,17 @@ English, please click [here](./HELP.md)
-
复合数据类型 array,需要验证响应消息中是否包含复合类型 object ?是,则需要验证 key 和数据类型;否则仅需要验证数据类型是否匹配期望。
##### 用例参考
[
点击此链接
](
/src/test/resources/features/sanitytest/backend.feature
)
-
[
点击此链接
](
/src/test/resources/features/sanitytest/backend.feature
)
-
!
[
结果截图
](
/gallery/sanity_test.png
)
##### 优点
无需测试人员手动编写测试脚本,测试框架全自动完成 OpenAPI 分析及 REST 消息的发送和结果验证。
##### 局限性
未考虑实际的业务需求;仅限于最基本的可行性验证。
-
无需测试人员手动编写测试脚本,测试框架全自动完成 OpenAPI 分析及 REST 消息的发送和结果验证。
-
根据不同微服务的自我定义,自动适配其支持的协议类型(如,http, https, http2等)进行消息的发送和接收。
-
执行速度快,436个 API,请求和验证可以在40秒内完成。
##### 局限性
-
未考虑实际的业务需求;仅限于最基本的可行性验证。
-
返回失败的请求需要人工二次校验其准确性(如果事先把测试数据准备好,则可规避此问题,但需要付出更多的人力)。
#### 1.1.2 编写符合实际业务需求的 API 测试用例(功能测试)
##### 测试方法
...
...
@@ -43,15 +49,15 @@ English, please click [here](./HELP.md)
-
否则打印错误断言,测试退出并标记为失败。
##### 用例参考
[
点击此链接
](
/src/test/resources/features/apitest/restful/user_management/user_register.feature
)
-
[
点击此链接
](
/src/test/resources/features/apitest/restful/user_management/user_register.feature
)
##### 优点
-
用例编写简单,核心测试脚本仅数行。
-
消息的发送、接收以及结果验证对用例编写人员透明。测试用例编写人员需要关心的只是产品业务需求。
-
测试数据与功能需求关联,支持复用。不同测试脚本(用例)可使用相同测试数据。
-
用例编写简单,核心测试脚本仅数行。
-
消息的发送、接收以及结果验证对用例编写人员透明。测试用例编写人员需要关心的只是产品业务需求。
-
测试数据与功能需求关联,支持复用。不同测试脚本(用例)可使用相同测试数据。
##### 局限性
更多需要讨论的是 API 测试本身的局限性,和本测试框架无关。
-
更多需要讨论的是 API 测试本身的局限性,和本测试框架无关。
#### 1.1.3 构造微服务 mock server,根据不同的请求返回不同的响应结果 (集成测试)
gallery/sanity_test.png
0 → 100644
View file @
d88f2d46
78.3 KB
src/main/java/com/fuzamei/autotest/openapi/OpenApiParser.java
View file @
d88f2d46
This diff is collapsed.
Click to expand it.
src/main/java/com/fuzamei/autotest/openapi/RestfulMessageEntity.java
View file @
d88f2d46
...
...
@@ -10,6 +10,7 @@ import lombok.Builder;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
import
java.util.Map
;
@Data
...
...
@@ -27,11 +28,15 @@ public class RestfulMessageEntity {
private
Map
<
String
,
Object
>
reqJsonBody
;
private
List
<
Object
>
reqJsonArrayBody
;
private
JsonNode
mapperReqJsonBody
;
private
int
statusCode
;
private
Map
<
String
,
Object
>
respJsonBody
;
private
List
<
Object
>
respJsonArrayBody
;
private
JsonNode
mapperRespJsonBody
;
}
src/main/java/com/fuzamei/autotest/openapi/RestfulMessageEventListener.java
View file @
d88f2d46
This diff is collapsed.
Click to expand it.
src/main/java/com/fuzamei/autotest/properties/BackendServiceProperties.java
View file @
d88f2d46
...
...
@@ -16,4 +16,5 @@ public class BackendServiceProperties {
private
String
port
;
private
String
openapifilepath
;
private
String
httpschema
;
private
Boolean
https
;
}
src/main/resources/application.properties
View file @
d88f2d46
...
...
@@ -14,9 +14,12 @@ server.port=8080
logging.level.root
=
WARN
logging.level.org.springframework
=
ERROR
logging.level.com.fuzamei.autotest
=
DEBUG
logging.config
=
classpath:logback-spring.xml
spring.jackson.default-property-inclusion
=
non_null
service.backend.httpschema
=
http://
service.backend.https
=
false
service.backend.httpschema
=
http1x
#service.backend.httpschema=http2
service.backend.host
=
172.22.18.152
service.backend.port
=
2345
service.backend.openapidefinitionpath
=
/
...
...
@@ -32,6 +35,6 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
mybatis.type-aliases-package
=
com.fuzamei.autotest.testdata.entity
mybatis.mapper-locations
=
classpath:mybatis/mapper/*.xml
restassured.connecttimeout
=
3000
restassured.requesttimeout
=
3000
restassured.sockettimeout
=
3000
\ No newline at end of file
restassured.connecttimeout
=
10000
restassured.requesttimeout
=
10000
restassured.sockettimeout
=
10000
\ No newline at end of file
src/main/resources/logback-spring.xml
0 → 100644
View file @
d88f2d46
This diff is collapsed.
Click to expand it.
src/test/java/com/fuzamei/autotest/steps/openapi/ApiVerification.java
View file @
d88f2d46
...
...
@@ -55,7 +55,7 @@ public class ApiVerification {
default
:
break
;
}
assertThat
(
openApiParser
.
analyzeOpenApiAndGenerateRequests
(
serviceName
,
targetServiceApiFilePath
),
is
(
Boolean
.
TRUE
)
);
openApiParser
.
analyzeOpenApiAndGenerateRequests
(
serviceName
,
targetServiceApiFilePath
);
}
@Then
(
"^Send RESTful request with dataNum (.*?) to verify interface .*?$"
)
...
...
src/test/resources/features/sanitytest/backend.feature
View file @
d88f2d46
...
...
@@ -4,4 +4,4 @@ Feature: API tests for service of backend
Scenario
:
Verify the exposed APIs work as design
Given
Found OpenAPI definition for backend service
When
The testing PERSISTENCE data orgUser is ready for backend service
#Then Analyze OpenAPI file of backend service and generate REST-ful requests automatically
\ No newline at end of file
Then
Analyze OpenAPI file of backend service and generate REST-ful requests automatically
\ 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