{"id":21638458,"url":"https://github.com/tingge/defensor-e2e-testing","last_synced_at":"2025-04-11T16:43:09.849Z","repository":{"id":45950793,"uuid":"145928092","full_name":"TingGe/defensor-e2e-testing","owner":"TingGe","description":"一套基于 “UI Recorder + F2eTest + 持续集成引擎 + 国际化报告服务 + Hubot + Docker + 大盘的Chrome扩展” 等技术二次开发的、可自动化运营的、用于 E2E 级功能测试的、自动化测试解决方案","archived":false,"fork":false,"pushed_at":"2023-12-08T09:11:42.000Z","size":4370,"stargazers_count":18,"open_issues_count":0,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T12:53:11.563Z","etag":null,"topics":["automated-testing","black-box-testing","docker","e2e","e2e-testing","functional-testing","uirecorder"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TingGe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-24T01:47:37.000Z","updated_at":"2025-03-18T03:20:23.000Z","dependencies_parsed_at":"2022-09-24T18:51:19.110Z","dependency_job_id":null,"html_url":"https://github.com/TingGe/defensor-e2e-testing","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TingGe%2Fdefensor-e2e-testing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TingGe%2Fdefensor-e2e-testing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TingGe%2Fdefensor-e2e-testing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TingGe%2Fdefensor-e2e-testing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TingGe","download_url":"https://codeload.github.com/TingGe/defensor-e2e-testing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248442373,"owners_count":21104170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automated-testing","black-box-testing","docker","e2e","e2e-testing","functional-testing","uirecorder"],"created_at":"2024-11-25T04:09:43.142Z","updated_at":"2025-04-11T16:43:09.820Z","avatar_url":"https://github.com/TingGe.png","language":"JavaScript","readme":"#  \u003cimg src=\"https://raw.githubusercontent.com/TingGe/defensor-e2e-testing/master/docs/logo.png\" width=\"60px\"\u003e Defensor E2E Testing\n\n一套基于 “UI Recorder + F2eTest + 持续集成引擎 + 国际化报告服务 + Hubot + Docker” 等技术二次开发的、可自动化运营的、用于 E2E 级功能测试的、自动化测试解决方案。\n\n## 目标\n\n```\n尽管诸多质量服务彼此之间风格殊异，却秉承着共同的坚定信念，那就是捍卫研发品质的崇高理想。\n合体成员理念上的共识，令守护神 Defensor 得以成为效能最高的合体战士。\nDefensor 一丝不苟的履行着自己的责任，守护着林林总总的产品体系。\n—— Defensor 宣言\n```\n\n作为测试矩阵中的“ E2E 级功能测试”，从全局视角提升测试效益、实时保障系统质量。\n\n## 准备\n\n### 安装前置依赖\n\n1. 安装 Nodejs : \u003chttps://nodejs.org/\u003e\n\n2. 配置 Nodejs 权限\n\n   \u003e `sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}`\n\n3. 安装 Chrome : \u003chttps://www.google.com/chrome/\u003e\n\n4. 安装 UI Recorder 及 mocha : `npm install uirecorder mocha -g`\n\n### 初始化 uitest 仓库 \n\n```bash\n# 下载测试代码仓库\ngit clone https://github.com/TingGe/defensor-e2e-testing.git\n\n# 安装仓库依赖\ncd ./defensor-e2e-testing\nnpm install\n```\n\n### 配置 host\n\n```bash\nsudo vim /etc/hosts\n\n# 添加 Defensor 配置\n127.0.0.1 hub\n```\n\n## 本机录制和回放\n\n### 启动 Server\n\n仅需在最初使用时安装，之后无需重复安装驱动\n\n```bash\nnpm run installdriver\n```\n\n启动 Server\n\n```bash\nnpm start\n```\n\n### 录制脚本\n\n以 “test.spec.js” 为例，实际场景中需将 `test` 替换为有意义的脚本名\n\n```bash\nuirecorder specs/test.spec.js\n```\n\n### 回放测试脚本\n\n```sh\nsh run.sh specs/test.spec.js\n# Windows 中执行 run.bat specs/test.spec.js\n```\n\n## 部署环境使用\n\n### 流程\n\n1. 安装 Docker 软件和 Defensor E2E Testing 的 Docker 镜像，并启动 Docker\n\n2. 启动容器\n\n   命令行方式：\n\n   ```bash\n   # 生产模式\n   docker-compose -f docker-compose.yml up -d --build\n   # 调试模式\n   docker-compose -f docker-compose.debug.yml up -d --build\n   ```\n\n   VS Code 插件方式：\n   https://marketplace.visualstudio.com/items?itemName=PeterJausovec.vscode-docker\n\n3. 实时查看 denfensor-testing 容器日志：\n\n   命令行方式：\n\n   ```bash\n   docker logs -f denfensor-testing\n   # 实时查看 denfensor-testing 容器最后10行日志\n   docker logs -f -t --tail 10 denfensor-testing\n   ```\n\n   Kitematic 软件方式：\n   https://kitematic.com/\n\n4. 关闭和清除容器\n\n   命令行方式：\n\n   ```bash\n   docker-compose down\n   docker system prune --volumes -f\n   ```\n\n   VS Code 插件方式：\n   https://marketplace.visualstudio.com/items?itemName=PeterJausovec.vscode-docker\n\n5. 在用户根目录的 reports 目录可查看生成的测试报告\n\n   ```bash\n   open ~/reports/index.html\n   ```\n\n### 技巧\n\n调试模式中，可通过 VNC viewer 方式查看 Chrome 容器中运行情况。\n\n1. 以 Mac 为例，右击 Dock 工具栏中的 Finder 图标，选择“连接服务器……”；\n2. “服务器地址：” 中填写 `vnc://127.0.0.1:5900`，并点击连接；\n3. “密码：” 中填入默认密码 `secret`，再点击连接即可进入运行的  `node-chrome-debug` 容器中。\n\n### Kubernetes 适配\n\n使用 [Kompose](https://github.com/kubernetes/kompose) 将 docker-compose.yml 配置转换为 Kubernetes 配置。\n\n## 最佳实践\n\n1. [黑盒测试用例设计方法](https://www.cnblogs.com/Jackc/archive/2009/02/24/1397433.html)\n2. [自动化最佳实践](https://github.com/TingGe/defensor-e2e-testing/blob/master/docs/best-practices.md)\n\n## 应用场景\n\n### 1. 研发环境，持续测试服务\n\n解决问题：减少重复工作，提升测试效能、保障产品质量。\n\n服务对象：（前端、后端和算法等）研发同学、业务测试同学、国际化测试同学和部分产品同学。\n\n技术方案： “UIRecorder + F2eTest + 持续集成引擎 + 国际化报告服务 + Hubot + 大盘的Chrome扩展” 技术方案。\n\n### 2. 私有部署环境，自动化验收工具\n\n解决问题： 提升乙方交付前验收测试效率。\n\n服务对象：交付现场的产品同学、负责交付的研发同学等。\n\n技术方案：VPN 远程支持和 “UI Recorder + Docker/Kubernetes + 报告生成” 两种技术方案。\n\n### 3. DevOps，成为CI/CD中标准环节\n\n解决问题： 持续保障不同环境和版本的功能质量。\n\n服务对象：研发同学、测试同学等。\n\n技术方案：同“2. 私有部署环境，自动化验收工具”。\n\n### 4. 线上环境，核心功能巡检服务\n\n解决问题：及时发现并反馈线上问题，降低故障影响范围\n\n服务对象：运维同学、运营同学、部分（前端、后端和算法等）研发同学和部分产品同学。\n\n技术方案： 同“1. 研发环境，持续测试服务”。\n\n## 参考\n\n- [基于Docker和Kubernetes的最佳架构实践](https://blog.csdn.net/AlbenXie/article/details/80419885)\n\n- [GitLab + Drone 构建 CI\u0026CD 环境](https://laravel-china.org/articles/17207)\n- [SpringBoot 集成 React 一体化打包部署](https://www.wanaright.com/2017/03/25/springboot-react-dva/)\n- [Macaca](https://www.anquanke.com/post/id/152729)\n\n## 许可 License\n\n[![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)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftingge%2Fdefensor-e2e-testing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftingge%2Fdefensor-e2e-testing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftingge%2Fdefensor-e2e-testing/lists"}