Skip to content

Commit

Permalink
📝 update env doc
Browse files Browse the repository at this point in the history
  • Loading branch information
defnngj committed Dec 28, 2024
1 parent 5c63820 commit 77452d3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
43 changes: 32 additions & 11 deletions docs/vpdocs/getting-started/data_driver.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ mypro/
.
└── test_data
├── develop
   └── test_data.json
└── test_data.json
├── product
   └── test_data.json
└── test_data.json
└── test
└── test_data.json
```
Expand All @@ -344,11 +344,11 @@ mypro/
```shell
.
├── develop
   └── test_data
   └── test_data.json
└── test_data
└── test_data.json
├── product
   └── test_data
   └── test_data.json
└── test_data
└── test_data.json
└── test
└── test_data
└── test_data.json
Expand All @@ -359,7 +359,6 @@ mypro/
```python
import seldom
from seldom import file_data
from seldom import Seldom
class MyTest(seldom.TestCase):
Expand All @@ -378,16 +377,38 @@ class MyTest(seldom.TestCase):
if __name__ == '__main__':
Seldom.env = "product" # test/develop/product 设置当前环境
seldom.main(debug=True)
# test/develop/product 设置当前环境
seldom.main(debug=True, env="product")
```

`Seldom.env` 默认为`None`,当设置了环境,`@file_data()` 会带上环境的目录名,例如:
`env` 默认为`None`,当设置了`环境变量`,`@file_data()`会带上`环境变量`的目录名,例如:

* `test_data.json` 查找的文件为 `product/test_data.json`
* `test_data/test_data.json` 查找的文件为 `product/test_data/test_data.json`

> `Seldom.env` 可以随意命名,但最好遵循一定的规范:`test/develop/product`。你还可以利用`Seldom.env`变量本地创建更多的配置。
> * `env` 可以随意命名,但最好遵循一定的规范,例如`test/develop/product`用于区分不同的环境。
> * 我们还可以利用`env`环境变量实现更多的配置,下面的示例。

```python
import seldom
from seldom import Seldom
class MyTest(seldom.TestCase):
def test_env(self):
if Seldom.env == "product":
username = "admin"
elif Seldom.env == "develop":
username = "guest"
else:
username = "tom"
...
if __name__ == '__main__':
seldom.main(debug=True, env="product")
```

### @api_data()方法

Expand Down
2 changes: 1 addition & 1 deletion docs/vpdocs/platform/platform.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ if __name__ == '__main__':
* `TestMainExtend(path="./test_dir")` : 其中`path`指定从哪个目录查找用例集合。
* `run_cases(cases)`: 运行用例。

### 接入平台比读
### 接入平台必读

如果你只是使用seldom框架编写用例,那么代码只要框架能运行即可,如果要接入seldom-platform平台,那么需要注意一下几点。

Expand Down

0 comments on commit 77452d3

Please sign in to comment.