Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mikigo committed Jul 19, 2024
1 parent 1ca8683 commit 27319e6
Show file tree
Hide file tree
Showing 12 changed files with 274 additions and 10 deletions.
5 changes: 3 additions & 2 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default defineConfig({
items: [
{text: "本地执行", link: "/指南/驱动执行/本地执行"},
{text: "远程执行", link: "/指南/驱动执行/远程执行"},
{text: "自定义驱动", link: "/指南/驱动执行/自定义驱动"},
{text: "自定义执行", link: "/指南/驱动执行/自定义执行"},
]
},
{
Expand All @@ -66,9 +66,10 @@ export default defineConfig({
{
text: "可选功能",
items: [
{text: "桌面UI自动化", link: "/指南/可选功能/桌面UI自动化"},
{text: "GUI自动化", link: "/指南/可选功能/GUI自动化"},
{text: "WebUI自动化", link: "/指南/可选功能/WebUI自动化"},
{text: "DBus自动化", link: "/指南/可选功能/DBus自动化"},
{text: "HTTP自动化", link: "/指南/可选功能/HTTP自动化"},
{text: "用例录屏", link: "/指南/可选功能/用例录屏"},
{text: "HTML报告", link: "/指南/可选功能/HTML报告"},
{text: "其他插件", link: "/指南/可选功能/其他插件"},
Expand Down
2 changes: 1 addition & 1 deletion docs/指南/与生俱来/全自动日志.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ DfmWidget.find_app_image("dfm_001")

自动输出的日志:

```shell
```bash
>> x86_64-uos-6: 02/28 17:48:47 | INFO | logger: [find_app_image]: 查找图片 dfm_001.png 在屏幕中相似度大于 0.9 的坐标
```

Expand Down
2 changes: 1 addition & 1 deletion docs/指南/与生俱来/标签化管理.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

当 “跳过原因” 和 “确认修复” 中同时填入后,命令行传递参数 `--ifixed yes`,则代码不会执行该条用例。

```shell
```bash
python3 manage.py run --ifixed yes
```

Expand Down
2 changes: 1 addition & 1 deletion docs/指南/环境管理/虚拟环境.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ youqu3-cargo run
`youqu3-shell` 可以激活虚拟环境,由于虚拟环境中也安装了 YouQu3 ,因此你仍然可以在虚拟环境中使用命令:`youqu3`

```bash
youqu3-shell
$ youqu3-shell
(my_virtualenv)$ youqu3 run
```

Expand Down
6 changes: 3 additions & 3 deletions docs/指南/简介/快速开始.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
pip install youqu3
```

```bash [桌面UI]
pip install "youqu3[desktop-ui]"
```bash [GUI]
pip install "youqu3[gui]"
```

```bash [WebUI]
Expand All @@ -35,7 +35,7 @@ pip install "youqu3[remote]"
::: tip 注意
- 根据不同的`测试类型`选择以上`不同的安装命令`,可以自动安装对应的依赖集。
- `基础环境`默认支持 `Linux 命令行自动化`
- 同时选择多个环境:`pip install "youqu3[desktop-ui, webui]"`
- 同时选择多个环境:`pip install "youqu3[gui, webui]"`
:::


Expand Down
178 changes: 178 additions & 0 deletions docs/指南/驱动执行/本地执行.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# 本地执行

## 子命令

本地执行子命令为:`run`
::: code-group

```bash [原生环境]
$ youqu3 run
```
```bash [虚拟环境]
$ youqu3-cargo run
```
:::

## 用例驱动方式

### 执行所有用例

::: code-group

```bash [原生环境]
$ youqu3 run
```

```bash [虚拟环境]
$ youqu3-cargo run
```

:::

### 指定执行某一个用例

```python
# test_xxx_001.py

class TestCase:

def test_xxx_001_1(self):
...

def test_xxx_001_2(self):
...
```

仅驱动执行这一条用例:

::: code-group

```bash [原生环境]
$ youqu3 run -k test_xxx_001_1
```
```bash [虚拟环境]
$ youqu3-cargo run -k test_xxx_001_1
```
:::

如果你想执行这个 py 文件中所有的用例:

::: code-group

```bash [原生环境]
$ youqu3 run -k test_xxx_001
```
```bash [虚拟环境]
$ youqu3-cargo run -k test_xxx_001
```
:::

### 指定某个目录执行

```shell
autotest-my-app
├── case
│   ├── base_case.py
│   ├── __init__.py
│   ├── smoke
│   │ ├── test_mycase_001.py
│   │ └── test_mycase_002.py
```
驱动执行 `smoke` 目录下所有用例:
::: code-group
```bash [原生环境]
$ youqu3 run -k smoke
```
```bash [虚拟环境]
$ youqu3-cargo run -k smoke
```
:::
### 根据关键词执行
执行包含关键词的用例,关键词可以是用例对象中的任意字符,且大小写不敏感
模块名称、py 文件名称、类名、函数名等等都可以做为关键词
比如:`case/test_music_001.py::TestMusic::test_music_001`
整个字符串中可以任意截取字符作为关键词。
关键词驱动支持` and/or/not` 表达式。
::: code-group
```bash [原生环境]
$ youqu3 run -k "music and 001"
```
```bash [虚拟环境]
$ youqu3-cargo run -k "music and 001"
```
:::
::: warning 注意:
使用逻辑表达式的时候一定要加引号:`"music and 001"`
:::
### 根据标签执行
基于 YouQu 特有的 CSV 文件管理的标签,也可以是传统的 Pytest 标签:`@pytest.mark.L1`
标签驱动支持` and/or/not` 表达式。
::: code-group
```bash [原生环境]
$ youqu3 run -t "L1 or smoke"
```
```bash [虚拟环境]
$ youqu3-cargo run -t "L1 or smoke"
```
:::
### 批量用例ID驱动执行
::: code-group
```bash [原生环境]
$ youqu3 run -t "id1 or id2 or id3 or id4"
```
```bash [虚拟环境]
$ youqu3-cargo run -t "id1 or id2 or id3 or id4"
```
:::
::: warning 注意:
使用逻辑表达式的时候一定要加引号:`"id1 or id2 or id3 or id4"`
:::
### 指定用例文件路径执行
指定用例文件
::: code-group
```bash [原生环境]
$ youqu3 run -f case/test_music_001.py
```
```bash [虚拟环境]
$ youqu3-cargo run -f case/test_music_001.py
```
:::
指定用例目录
::: code-group
```bash [原生环境]
$ youqu3 run -f case
```
```bash [虚拟环境]
$ youqu3-cargo run -f case
```
:::
用例文件、目录组合
::: code-group
```bash [原生环境]
$ youqu3 run -f "case/test_music_001.py case/test_music_002.py"
```
```bash [虚拟环境]
$ youqu3-cargo run -f "case/test_music_001.py case/test_music_002.py"
```
:::
::: warning 注意:
多个用例文件、目录之间用空格分割,加引号
:::
22 changes: 22 additions & 0 deletions docs/指南/驱动执行/自定义执行.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 自定义执行

YouQu3 支持在 txt 文件中自定义用例集驱动执行:

- youqu-tags.txt
- youqu-keywords.txt

## youqu-tags.txt

在根目录下定义 `youqu-tags.txt` 文件,YouQu3 会自动加载并执行。

`youqu-tags.txt` 文件里面写标签的表达式,如:

::: tip youqu-tags.txt

id1 or id2 or id3

:::



## youqu-keywords.txt
63 changes: 63 additions & 0 deletions docs/指南/驱动执行/远程执行.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# 远程执行

## 子命令

远程执行就是用本地作为服务端控制远程机器执行,远程机器执行的用例相同;

远程执行使用子命令: `remote`

::: code-group
```bash [原生环境]
$ youqu3 remote -e
```
```bash [虚拟环境]
$ youqu3-cargo remote -e
```
:::

::: details 开启 SSH
执行前确保远程机器已经开启了 `SSH` 服务,否则会提示无法连接:


```bash
$ sudo systemctl restart ssh
```

:::

## 远程测试机分组策略

### 分组规则

一对大括号表示一个组:

```txt
{user1@ip1/user2@ip2}{user3@ip3/user4@ip4}
```

以上写法表示有 2 个组(group):

- `group1` : `user1@ip1/user2@ip2`
- `group2` : `user3@ip3/user4@ip4`

### 执行策略

::: tip 规则概述

**`同一组内瓜分执行,不同组之间相同执行`**

:::

::: code-group
```bash [原生环境]
$ youqu3 remote -c "{user1@ip1/user2@ip2}{user3@ip3/user4@ip4}"
```
```bash [虚拟环境]
$ youqu3-cargo remote -c "{user1@ip1/user2@ip2}{user3@ip3/user4@ip4}"
```
:::

假设总共 100 条用例:

- `group1``group2``同时执行 100 条`
- `group1` 包含 2 个测试机,2 个机器瓜分 100 条用例,`每个机器执行 50 条`
2 changes: 1 addition & 1 deletion docs/规划/YouQu3架构设计规划.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Author : mikigo

## 1. 背景

YouQu(`YouQu2`) 是 2021 年成都测试团队开始内部孵化的项目,旨在开发一个简单易用,功能强大的自动化测试框架。经过了 2 年多的持续开发优化,2023 年 8 月正式在 linuxdeepin 社区开源,2024 年 5 月在欧拉社区开源。从开源至今发布了 1.0 和 2.0 两个大版本,小版本更新了数十个。
YouQu([`YouQu2`](https://github.com/linuxdeepin/youqu)) 是 2021 年成都测试团队开始内部孵化的项目,旨在开发一个简单易用,功能强大的自动化测试框架。经过了 2 年多的持续开发优化,2023 年 8 月正式在 [linuxdeepin](https://github.com/linuxdeepin/) 社区开源,2024 年 5 月在欧拉社区开源。从开源至今发布了 1.0 和 2.0 两个大版本,小版本更新了数十个。

YouQu2 在公司内部已经被大量的自动化测试项目使用,在公司的多个自动化流程中运行得很好,能满足公司对自动化测试的业务需求,也得到了公司领导、同事们、内外部开发者们的认可。

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ readme = "README.md"
license = { text = "GPL2.0" }

[project.optional-dependencies]
desktop-ui = [
gui = [
"pylinuxauto",
"youqu-html",
]
Expand Down

0 comments on commit 27319e6

Please sign in to comment.