Skip to content

Commit 2da90be

Browse files
author
北渔
committed
Init
1 parent 9983d08 commit 2da90be

19 files changed

+1215
-1
lines changed

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules
2+
npm-debug.log
3+
Dockerfile*
4+
docker-compose*
5+
.dockerignore
6+
.git
7+
.gitignore
8+
README.md
9+
LICENSE
10+
.vscode

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
# Apply for all files
8+
[*]
9+
10+
charset = utf-8
11+
12+
indent_style = space
13+
indent_size = 2
14+
15+
end_of_line = lf
16+
insert_final_newline = true
17+
trim_trailing_whitespace = true

.vscode/launch.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
// Use IntelliSense to learn about possible Node.js debug attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Debug UIRecorder Local",
11+
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
12+
"cwd": "${workspaceRoot}",
13+
"args": ["--reporter", "mochawesome-uirecorder", "${file}"],
14+
"env": {
15+
"webdriver": "127.0.0.1"
16+
}
17+
},
18+
{
19+
"type": "node",
20+
"request": "launch",
21+
"name": "Debug UIRecorder Default",
22+
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
23+
"cwd": "${workspaceRoot}",
24+
"args": ["--reporter", "mochawesome-uirecorder", "${file}"]
25+
}
26+
]
27+
}

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM node:10.8.0-stretch
2+
ENV NODE_ENV production
3+
WORKDIR /usr/defensor/e2eTest
4+
COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"]
5+
RUN npm install --production --silent
6+
COPY . .

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Kevin
3+
Copyright (c) 2018 Kevin TingGe<[email protected]>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Defensor E2E Testing 使用说明
2+
3+
一套基于 “UIRecorder + Docker” 二次开发的、可自动化运营的、 端到端级别的功能回归的自动化测试解决方案。
4+
5+
## 准备
6+
7+
安装、录制和回放,请参考 [UI Recorder](https://github.com/alibaba/uirecorder)
8+
9+
## 使用
10+
11+
1. 安装 Defensor E2E Testing 的 Docker 镜像
12+
13+
2. 启动容器
14+
15+
命令行方式:
16+
17+
```bash
18+
# 生产模式
19+
docker-compose -f docker-compose.yml up -d --build
20+
# 调试模式
21+
docker-compose -f docker-compose.debug.yml up -d --build
22+
```
23+
24+
VS Code 插件方式:
25+
https://marketplace.visualstudio.com/items?itemName=PeterJausovec.vscode-docker
26+
27+
3. 实时查看 denfensor-testing 容器日志:
28+
29+
命令行方式:
30+
31+
```bash
32+
docker logs -f denfensor-testing
33+
# 实时查看 denfensor-testing 容器最后10行日志
34+
docker logs -f -t --tail 10 denfensor-testing
35+
```
36+
37+
Kitematic 软件方式:
38+
https://kitematic.com/
39+
40+
4. 关闭和清除容器
41+
42+
命令行方式:
43+
44+
```bash
45+
docker-compose down
46+
docker system prune --volumes -f
47+
```
48+
49+
VS Code 插件方式:
50+
https://marketplace.visualstudio.com/items?itemName=PeterJausovec.vscode-docker
51+
52+
5. 在用户根目录的 reports 目录可查看生成的测试报告
53+
54+
```bash
55+
open ~/reports/index.html
56+
```
57+
58+
## 技巧
59+
60+
调试模式中,可通过 VNC viewer 方式查看 Chrome 容器中运行情况。
61+
62+
1. 以 Mac 为例,右击 Dock 工具栏中的 Finder 的图标,选择“连接服务器……”;
63+
2. “服务器地址:” 中填写 `vnc://127.0.0.1:5900`,并点击连接;
64+
3. “密码:” 中填入默认密码 `secret`,再点击连接即可进入运行的 `node-chrome-debug` 容器中。
65+
66+
## 许可
67+
68+
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2FTingGe%2Fdefensor-e2e-testing.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2FTingGe%2Fdefensor-e2e-testing?ref=badge_large)

commons/commons.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Please save common test case here.

config.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"webdriver": {
3+
"host": "hub",
4+
"port": "4444",
5+
"browsers": "chrome"
6+
},
7+
"vars": {
8+
"test_url": "https://baidu.com/"
9+
},
10+
"recorder": {
11+
"pathAttrs": "data-id,data-name,type,data-type,role,data-role,data-value",
12+
"attrValueBlack": "",
13+
"classValueBlack": "",
14+
"hideBeforeExpect": ""
15+
}
16+
}

docker-compose.debug.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: "2.1"
2+
3+
services:
4+
hub:
5+
container_name: hub
6+
image: selenium/hub:3.14.0-arsenic
7+
ports:
8+
- "4444:4444" # for webdriver
9+
node-chrome-debug:
10+
container_name: node-chrome-debug
11+
image: selenium/node-chrome-debug:3.14.0-arsenic
12+
ports:
13+
- "5900:5900" # for VNC viewer
14+
depends_on:
15+
- hub
16+
environment:
17+
- HUB_PORT_4444_TCP_ADDR=hub
18+
- HUB_PORT_4444_TCP_PORT=4444
19+
denfensor-testing:
20+
container_name: denfensor-testing
21+
image: denfensor-testing
22+
build: .
23+
command: npm test
24+
volumes:
25+
- ~/reports:/usr/defensor/e2eTest/reports
26+
shm_size: 4G
27+
depends_on:
28+
- hub
29+
- node-chrome-debug

docker-compose.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: "2.1"
2+
3+
services:
4+
hub:
5+
container_name: hub
6+
image: selenium/hub:3.14.0-arsenic
7+
ports:
8+
- "4444:4444" # for webdriver
9+
node-chrome:
10+
container_name: node-chrome
11+
image: selenium/node-chrome:3.14.0-arsenic
12+
depends_on:
13+
- hub
14+
environment:
15+
- HUB_PORT_4444_TCP_ADDR=hub
16+
- HUB_PORT_4444_TCP_PORT=4444
17+
denfensor-testing:
18+
container_name: denfensor-testing
19+
image: denfensor-testing
20+
build: .
21+
command: npm test
22+
volumes:
23+
- ~/reports:/usr/defensor/e2eTest/reports
24+
shm_size: 4G
25+
depends_on:
26+
- hub
27+
- node-chrome

0 commit comments

Comments
 (0)