Skip to content

Commit

Permalink
add reference
Browse files Browse the repository at this point in the history
  • Loading branch information
dengnao-tw committed Oct 25, 2023
1 parent fdaeec7 commit 0b60abe
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 60 deletions.
66 changes: 36 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,22 @@
- [验证 status code 为 200](#验证-status-code-为-200)
- [Assert repsponse body 符合预期](#assert-repsponse-body-符合预期-1)
- [调试 Tests](#调试-tests)
- [环境变量](#环境变量)
- [创建环境变量](#创建环境变量)
- [环境变量 demo](#环境变量-demo)
- [使用环境变量](#使用环境变量)
- [测试脚本接口自动化](#测试脚本接口自动化)
- [前置条件](#前置条件)
- [接口自动化项目 demo](#接口自动化项目-demo)
- [接入 CI](#接入-ci)
- [接入 github action](#接入-github-action)
- [测试报告---TODO](#测试报告---todo)
- [bruno 更多用法---TODO](#bruno-更多用法---todo)
- [Postman 脚本迁移](#postman-脚本迁移)
- [API 请求集迁移](#api-请求集迁移)
- [环境变量迁移](#环境变量迁移)
- [测试脚本迁移参考](#测试脚本迁移参考)
- [环境变量](#环境变量)
- [创建环境变量](#创建环境变量)
- [环境变量 demo](#环境变量-demo)
- [使用环境变量](#使用环境变量)
- [测试脚本接口自动化](#测试脚本接口自动化)
- [前置条件](#前置条件)
- [接口自动化项目 demo](#接口自动化项目-demo)
- [接入 CI](#接入-ci)
- [接入 github action](#接入-github-action)
- [测试报告---TODO](#测试报告---todo)
- [bruno 更多用法---TODO](#bruno-更多用法---todo)
- [Postman 脚本迁移](#postman-脚本迁移)
- [API 请求集迁移](#api-请求集迁移)
- [环境变量迁移](#环境变量迁移)
- [测试脚本迁移参考](#测试脚本迁移参考)
- [参考资料](#参考资料)

## 为什么选择 bruno

Expand Down Expand Up @@ -268,17 +269,17 @@ expect(data.title).to.contains('provident');

![tests-demo](/readme_pictures/tests-demo.png)

#### 环境变量
## 环境变量

##### 创建环境变量
### 创建环境变量

- 前置条件:已经创建了 API 请求集和 API 请求 (参考上面的创建 API 请求集和新建 API 请求)
- 选择想要创建环境变量的 API 请求
- 点击页面右上角的‘No Environment’链接(默认为 No Environment),选择菜单中的 configure 按钮即可打开环境变量管理弹窗(支持创建新的环境变量和导入已有的环境变量)
- 弹窗上点击 Create Environment 按钮,输入环境变量的名字,点击 create 按钮即可创建环境变量
- 然后在弹窗上点击 Add Variable 按钮,输入环境变量的 key 和 value,点击 Save 按钮即可添加环境变量

##### 环境变量 demo
### 环境变量 demo

> 需求:创建一个 demo 环境变量,里面包含一个 key 为 host,value 为 <https://jsonplaceholder.typicode.com> 的环境变量
Expand All @@ -289,23 +290,23 @@ expect(data.title).to.contains('provident');
- 如下图所示
![env-intro](/readme_pictures/env-intro.png)

##### 使用环境变量
### 使用环境变量

- 前置条件:已经创建了 API 请求集和 API 请求 (参考上面的创建 API 请求集和新建 API 请求),也创建了 demo 环境变量
- 选择想要使用环境变量的 API 请求
- 点击页面右上角的‘No Environment’链接(默认为 No Environment),选择菜单中的 demo 按钮即可使用 demo 环境变量
- 然后在 API 请求的 URL 变更为输入 {{host}}/posts/1 即可使用环境变量

### 测试脚本接口自动化
## 测试脚本接口自动化

#### 前置条件
### 前置条件

- [x] 已创建了 API 请求集(示例名为:api-collects
- [x] 已创建了 API 请求(示例名为:api request1)
- [x] 已创建了环境变量(示例名为:demo
- [x] 也为 API 请求编写了 assert 或者 tests 脚本

#### 接口自动化项目 demo
### 接口自动化项目 demo

- [x] 安装 node.js
- [x] 安装 npm
Expand Down Expand Up @@ -336,9 +337,9 @@ bruno-test //项目主文件夹

![cli-demo](/readme_pictures/cli-demo.png)

### 接入 CI
## 接入 CI

#### 接入 github action
### 接入 github action

> 以 github action 为例,其他 CI 工具类似
Expand Down Expand Up @@ -377,13 +378,13 @@ jobs:
![cli-demo1](/readme_pictures/cli-demo1.png)
> 可拉取本项目代码进行参考:<https://github.com/dengnao-tw/Bruno-API-Test-Starter>
#### 测试报告---TODO
## 测试报告---TODO
### bruno 更多用法---TODO
## bruno 更多用法---TODO
### Postman 脚本迁移
## Postman 脚本迁移
#### API 请求集迁移
### API 请求集迁移
- 在首页点击‘Import Collection’链接,打开导入 API collection 的弹窗
- 点击选择 Postman Collection 的链接,再选在已存在的 Postman 请求集文件路径
Expand All @@ -392,7 +393,7 @@ jobs:
![postman1](/readme_pictures/postman1.png)
![bruno1](/readme_pictures/bruno1.png)
#### 环境变量迁移
### 环境变量迁移
- 在首页选择刚才导入的 Postman 请求
- 点击页面右上角的‘No Environment’链接(默认为 No Environment),选择菜单中的 configure 按钮即可打开环境变量管理弹窗
Expand All @@ -402,7 +403,7 @@ jobs:
![postman2](/readme_pictures/postman2.png)
![bruno2](/readme_pictures/bruno2.png)
#### 测试脚本迁移参考
### 测试脚本迁移参考
>两个工具测试脚本的语法存在一部分差异,需要手动修改
Expand Down Expand Up @@ -434,3 +435,8 @@ test("res.body should be correct", function() {
expect(data.title).to.contains('provident');
});
```

## 参考资料

- [bruno 官方文档](https://docs.usebruno.com/)
- [bruno 官方 github](https://github.com/usebruno/bruno)
66 changes: 36 additions & 30 deletions README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,22 @@
- [Verify status code is 200](#verify-status-code-is-200)
- [Verify repsponse body as expected](#verify-repsponse-body-as-expected)
- [Debugging Tests](#debugging-tests)
- [environment variables](#environment-variables)
- [Creating Environment Variables](#creating-environment-variables)
- [environment variable demo](#environment-variable-demo)
- [Using Environment Variables](#using-environment-variables)
- [Test script automation](#test-script-automation)
- [Pre-conditions](#pre-conditions)
- [api automation project demo](#api-automation-project-demo)
- [Getting into CI](#getting-into-ci)
- [Getting into github action](#getting-into-github-action)
- [Test report---TODO](#test-report---todo)
- [bruno More usage---TODO](#bruno-more-usage---todo)
- [Postman script migration](#postman-script-migration)
- [API Request Collection Migration](#api-request-collection-migration)
- [Environment Variable Migration](#environment-variable-migration)
- [Test Script Migration Reference](#test-script-migration-reference)
- [environment variables](#environment-variables)
- [Creating Environment Variables](#creating-environment-variables)
- [environment variable demo](#environment-variable-demo)
- [Using Environment Variables](#using-environment-variables)
- [Test script automation](#test-script-automation)
- [Pre-conditions](#pre-conditions)
- [api automation project demo](#api-automation-project-demo)
- [CI/CD Integration](#cicd-integration)
- [Integration github action](#integration-github-action)
- [Test report---TODO](#test-report---todo)
- [bruno More usage---TODO](#bruno-more-usage---todo)
- [Postman script migration](#postman-script-migration)
- [API Request Collection Migration](#api-request-collection-migration)
- [Environment Variable Migration](#environment-variable-migration)
- [Test Script Migration Reference](#test-script-migration-reference)
- [reference](#reference)

## why bruno

Expand Down Expand Up @@ -268,17 +269,17 @@ expect(data.title).to.contains('provident');

![tests-demo](/readme_pictures/tests-demo.png)

#### environment variables
## environment variables

##### Creating Environment Variables
### Creating Environment Variables

- Prerequisites: An API request set and an API request have already been created (see Creating an API request set and New API request above).
- Select the API request for which you want to create an environment variable
- Click the 'No Environment' link in the upper right corner of the page (default is No Environment) and select the configure button in the menu to open the environment variable management popup window (supports creating new environment variables and importing existing environment variables).
- Click Create Environment button on the popup window, enter the name of the environment variable and click create button to create the environment variable.
- Then click Add Variable button on the popup window, enter the key and value of the environment variable, and click Save button to add the environment variable.

##### environment variable demo
### environment variable demo

> Requirement: Create a demo environment variable that contains an environment variable with key host and value <https://jsonplaceholder.typicode.com>.
Expand All @@ -289,23 +290,23 @@ expect(data.title).to.contains('provident');
- As shown in the following figure
! [env-intro](/readme_pictures/env-intro.png)

##### Using Environment Variables
### Using Environment Variables

- Prerequisites: You have already created an API request set and an API request (see Creating an API request set and creating a new API request above), and you have also created a demo environment variable.
- Select the API request for which you want to use environment variables
- Click the 'No Environment' link in the top right corner of the page (default is No Environment), and select the demo button in the menu to use the demo environment variable.
- Then change the URL of the API request to {{host}}/posts/1 to use the environment variable.

### Test script automation
## Test script automation

#### Pre-conditions
### Pre-conditions

- [x] API request set has been created (example named :api-collects)
- [x] API request has been created (example name: api request1)
- [x] an environment variable has been created (example name: demo)
- [x] has also written an assert or tests script for the API request

#### api automation project demo
### api automation project demo

- [x] Installed node.js
- [x] Install npm
Expand Down Expand Up @@ -336,9 +337,9 @@ bruno-test //项目主文件夹

![cli-demo](/readme_pictures/cli-demo.png)

### Getting into CI
## CI/CD Integration

#### Getting into github action
### Integration github action

> Take github action as an example, other CI tools are similar.
Expand Down Expand Up @@ -377,13 +378,13 @@ jobs:
![cli-demo1](/readme_pictures/cli-demo1.png)
> The code for this project can be pulled for reference:<https://github.com/dengnao-tw/Bruno-API-Test-Starter>
#### Test report---TODO
## Test report---TODO
### bruno More usage---TODO
## bruno More usage---TODO
### Postman script migration
## Postman script migration
#### API Request Collection Migration
### API Request Collection Migration
- Click on the 'Import Collection' link on the home page to open the Import API collection popup window.
- Click on the Select Postman Collection link and select the path to an existing Postman request collection file.
Expand All @@ -392,7 +393,7 @@ jobs:
![postman1](/readme_pictures/postman1.png)
![bruno1](/readme_pictures/bruno1.png)
#### Environment Variable Migration
### Environment Variable Migration
- Select the Postman request you just imported on the home page.
- Click the 'No Environment' link in the upper right corner of the page (default is No Environment), and select the configure button in the menu to open the environment variable management popup window.
Expand All @@ -403,7 +404,7 @@ jobs:
![postman2](/readme_pictures/postman2.png)
![bruno2](/readme_pictures/bruno2.png)
#### Test Script Migration Reference
### Test Script Migration Reference
>The syntax of the test scripts for the two tools is partially different and needs to be modified manually
Expand Down Expand Up @@ -435,3 +436,8 @@ test("res.body should be correct", function() {
expect(data.title).to.contains('provident');
});
```

## reference

- [bruno Official document](https://docs.usebruno.com/)
- [bruno Official github](https://github.com/usebruno/bruno)

0 comments on commit 0b60abe

Please sign in to comment.