This repository has been archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Description: Log:
- Loading branch information
Showing
13 changed files
with
513 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# JSON 报告 | ||
|
||
框架默认生成 JSON 报告,在用例工程目录下生成报告文件: `/report/json/report_xxxx.json` | ||
|
||
## 报告内容 | ||
|
||
### 整体结构 | ||
|
||
```json | ||
{ | ||
"created": 1518371686.7981803, | ||
"duration": 0.1235666275024414, | ||
"exitcode": 1, | ||
"root": "/path/to/tests", | ||
"environment": ENVIRONMENT, | ||
"summary": SUMMARY, | ||
"collectors": COLLECTORS, | ||
"tests": TESTS, | ||
"warnings": WARNINGS, | ||
} | ||
``` | ||
|
||
### Environment | ||
|
||
环境信息 | ||
|
||
```json | ||
{ | ||
"Python": "3.6.4", | ||
"Platform": "Linux-4.56.78-9-ARCH-x86_64-with-arch", | ||
"Packages": { | ||
"pytest": "3.4.0", | ||
"py": "1.5.2", | ||
"pluggy": "0.6.0" | ||
}, | ||
"Plugins": { | ||
"xdist": "1.22.0", | ||
"metadata": "1.5.1", | ||
}, | ||
"foo": "bar" | ||
} | ||
``` | ||
|
||
### Summary | ||
|
||
汇总信息 | ||
|
||
```json | ||
{ | ||
"collected": 10, | ||
"passed": 2, | ||
"failed": 3, | ||
"xfailed": 1, | ||
"xpassed": 1, | ||
"error": 2, | ||
"skipped": 1, | ||
"total": 10 | ||
} | ||
``` | ||
|
||
### Collectors | ||
|
||
收集器节点的列表,默认关闭,不显示。 | ||
|
||
### Tests | ||
|
||
每个用例的详细结果 | ||
|
||
```json | ||
[ | ||
{ | ||
"nodeid": "test_foo.py::test_fail", | ||
"lineno": 50, | ||
"keywords": [ | ||
"test_fail", | ||
"test_foo.py", | ||
"test_foo0" | ||
], | ||
"outcome": "failed", | ||
"setup": TEST_STAGE, | ||
"call": TEST_STAGE, | ||
"teardown": TEST_STAGE, | ||
"metadata": { | ||
"foo": "bar", | ||
} | ||
}, | ||
... | ||
] | ||
``` | ||
|
||
### Warnings | ||
|
||
警告信息 | ||
|
||
```json | ||
[ | ||
{ | ||
"code": "C1", | ||
"path": "/path/to/tests/test_foo.py", | ||
"nodeid": "test_foo.py::TestFoo", | ||
"message": "cannot collect test class 'TestFoo' because it has a __init__ constructor" | ||
} | ||
] | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# 前后钩子 | ||
|
||
YouQu3 提供灵活的前后钩子机制。 | ||
|
||
## 前置钩子 | ||
|
||
### 前置脚本钩子 | ||
|
||
在用例工程目录下存放一个 `job_start.py` 的脚本,框架会在用例执行之前自动加载并执行。 | ||
|
||
```bash | ||
my_case | ||
├── case | ||
├── method | ||
├── job_start.py # [!code focus] | ||
... | ||
``` | ||
### 前置命令行入参钩子 | ||
框架支持通过 `--job-start` 入参,参数值可以传递任意命令行命令,框架会在用例执行之前执行。 | ||
```bash | ||
youqu3 run --job-start "python3 do_what_you_want_do.py" | ||
``` | ||
就像写 Shell 脚本一样即可: | ||
```bash | ||
youqu3 run --job-start "sudo apt install htop;git clone ..." | ||
``` | ||
## 后置钩子 | ||
### 后置脚本钩子 | ||
在用例工程目录下存放一个 `job_start.py` 的脚本,框架会在用例执行之前自动加载并执行。 | ||
```bash | ||
my_case | ||
├── case | ||
├── method | ||
├── job_end.py # [!code focus] | ||
... | ||
``` | ||
### 后置命令行入参钩子 | ||
框架支持通过 `--job-end` 入参,参数值可以传递任意命令行命令,框架会在用例执行之前执行。 | ||
```bash | ||
youqu3 run --job-end "python3 do_what_you_want_do.py" | ||
``` | ||
就像写 Shell 脚本一样即可: | ||
```bash | ||
youqu3 run --job-end "sudo apt install htop;git clone ..." | ||
``` | ||
## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# 动态等待 | ||
|
||
## 架构动态等待 | ||
|
||
```python | ||
from youqu3 import sleep | ||
|
||
sleep(1) | ||
``` | ||
|
||
可以完全代替之前这样的写法: | ||
|
||
```python | ||
from time import sleep | ||
``` | ||
|
||
优化: | ||
|
||
- 增加了等待的日志 | ||
|
||
- 根据不同的架构对等待时间进行倍数放大,各架构倍数: | ||
|
||
```ini | ||
x86_64 = 1 | ||
aarch64 = 1.5 | ||
loongarch64 = 2 | ||
mips64 = 2.5 | ||
sw_64 = 2.5 | ||
``` | ||
|
||
## 元素识别动态等待 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# 命令行交互 | ||
|
||
## 本机命令行交互 | ||
|
||
### 普通权限执行 | ||
|
||
```python | ||
from youqu3.cmd import Cmd | ||
|
||
Cmd.run("ls") | ||
``` | ||
|
||
### sudo权限执行 | ||
|
||
```python | ||
from youqu3.cmd import Cmd | ||
|
||
Cmd.sudo_run("apt install htop") | ||
``` | ||
|
||
### expect交互 | ||
|
||
```python | ||
from youqu3.cmd import Cmd | ||
|
||
Cmd.expect_run( | ||
"ssh username@machine_ip 'ls -l'", | ||
events={'password':'secret\n'} | ||
) | ||
``` | ||
|
||
## 远程命令行交互 | ||
|
||
### 普通权限执行 | ||
|
||
```python | ||
from youqu3.cmd import RemoteCmd | ||
|
||
RemoteCmd("user", "ip", "password").remote_run("ls -l") | ||
``` | ||
|
||
### sudo权限执行 | ||
|
||
```python | ||
from youqu3.cmd import RemoteCmd | ||
|
||
RemoteCmd("user", "ip", "password").remote_sudo_run("apt install htop") | ||
``` | ||
|
||
### expect交互 | ||
|
||
```python | ||
from youqu3.cmd import RemoteCmd | ||
|
||
# TODO | ||
# RemoteCmd("user", "ip", "password").remote_expect_run("sudo apt install htop") | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# 断言语句 | ||
|
||
YouQu3 自带多种断言语句,几乎满足了所有的断言场景; | ||
|
||
![](/指南/与生俱来/assert.png) | ||
|
||
## 用例中使用方法 | ||
|
||
APP 工程自有断言模块:`assert_method.py`,它继承了 YouQu3 框架的断言库: | ||
|
||
```python | ||
# assert_method.py | ||
|
||
from youqu3.assertx import Assert | ||
|
||
class AssertMethod(Assert): | ||
"""AssertMethod""" | ||
|
||
``` | ||
|
||
用例基类 `BaseCase` 继承 `AssertMethod`: | ||
|
||
```python | ||
# base_case.py | ||
|
||
from method.assert_method import AssertMethod | ||
from youqu3.webui import WebAssert | ||
|
||
class BaseCase(AssertMethod, WebAssert): | ||
"""用例基类""" | ||
``` | ||
|
||
用例中通过 `self` 调用所有的断言语句: | ||
|
||
```python | ||
class TestMyCase(BaseCase): | ||
|
||
def test_mycase_001(self): | ||
"""my case 001""" | ||
self.assert_xxx | ||
``` | ||
|
||
## 方法明细 | ||
|
||
```python | ||
<!--@include: ../../../youqu3/assertx.py--> | ||
``` | ||
|
||
|
||
|
Oops, something went wrong.