Contents
Installation
pip install xiaoli-autotest-pytest
Usage
1. cli-run
pytest --csv=script/test_hello.csv --slowtime=1000 --headless
cases/test_main.py::test_http_api[Print hello]
Test Case => {'case_id': '0001', 'case_name': 'Test hello', 'step_name': 'Print hello', 'protocols': 'http_api', 'route': 'mods.hello.hello.print_hello', 'parameter': '', 'scope': 'dev'}
=> Load route mods.hello.hello success
=> Load class Hello success
=> Load cases print_hello success
hello
PASSED
2. Parameter Description
| Parameters | Type | Required | Description |
|---|---|---|---|
| --csv | str | Yes | Your script file name |
| --slowtime | int | No | The interval of each step of the UI test, in milliseconds, the default 1000ms is 1 second |
| --headless | boolean | No | Whether to enable headless mode (no browser mode) during UI test |
3. Test Case Script
Create a csv script file in the script directory, e.g. <test_hello.csv>
case_id,case_name,step_id,step_name,method,route,parameter,hard_assert,scope
0001,Test hello,1,Print hello,test_http_api,hello.hello.print_hello,,false,dev
Note: It can be created or opened in Excel, and must be saved in "CSV UTF-8(Comma delimited)" format to avoid garbled Chinese characters. Save as "UTF-8" when using other text tools
4. Test Case Field Description
| Parameters | Type | Required | Description |
|---|---|---|---|
| case_id | str | Yes | Test case number, unique |
| case_name | str | Yes | Test case name |
| step_name | str | Yes | Test case step |
| protocols | str | Yes | Test Protocol http_api: http interface test playwright: UI test driven |
| route | str | Yes | Test class-to-method routing, all lowercase underscores |
| parameter | str | No | Test parameter |
| scope | str | Yes | Test scope, default: smoke, dev, test, stage, etc. |
Report
allure-results is generated by default under the project root directory. The development environment does not automatically generate Allure Report HTML, you need to manually generate and open the html report:
allure serve allure-results
Docker
1. docker pull
docker push roger813/xiaoli-autotest-pytest:tag
2. rename image
Note: This step is optional, if you do not change the name, then the image name in the next step needs to be replaced with the full name
docker tag roger813/xiaoli-autotest-pytest:tag xiaoli-autotest-pytest
3. verify image
docker run -d --name pytest -p 8080:8080 xiaoli-autotest-pytest
- Open the container and the log is displayed: Report successfully generated to allure-report, Images are available.
- Open your browser to access the allure report: http://localhost:8080
- If the following page is displayed, the image is successfully pulled
4. business Test
cd your-project-directory
docker run -d --name pytest -p 8080:8080 -v %cd%\assets:/work/assets -v %cd%\confs:/work/confs -v %cd%\mods:/work/mods -v %cd%\script:/work/script -e csv=custom.csv swpic-autotest-pytest
- Go to your project directory
- Mount the assets, confs, mods, and script directories in the service project
- Add environmental parameters
- -e csv=your_script_file.csv(required)
- -e scope=dev(optional), Determine your test scope, default to full environment testing
- Open your browser to access the allure report: http://localhost:8080
DevOps
Jenkins Pipeline
parameters {
string(
name: 'SCRIPT',
defaultValue: 'your_test_script.csv',
description: '测试脚本CSV文件, 描述测试业务逻辑(必须)')
string(
name: 'TEST_SCOPE',
defaultValue: 'dev,test,stage,smoke,regress',
description: '测试范围, 默认全范围测试. 选择需要测试的用例范围(可选)')
// string(
// name: 'SLOW_TIME',
// defaultValue: '1000',
// description: '测试间隔, UI测试中每一步操作间隔时间, 单位毫秒(可选)')
string(
name: 'BUSINESS_BRANCH',
defaultValue: 'dev',
description: '测试代码仓库分支(可选)')
booleanParam(
name: 'PARALLEL_TEST',
defaultValue: false,
description: '是否多线程, 默认关闭. 适用于没有依赖关系的用例集(可选)')
}
| Parameters | Description | Required | Proposal |
|---|---|---|---|
| SCRIPT | your_script_file | Yes | |
| TEST_SCOPE | test scope | Yes | |
| SLOW_TIME | test interval | No | If it is not a UI test project, you do not need it |
| BUSINESS_BRANCH | Branch of the business repo | Yes | Quickly verify branch correctness and avoid unnecessary merging efforts |
| PARALLEL_TEST | Whether to enable multithreading | No | Enable this, speed up the test, use cases have dependencies and use with caution |
run with parameter
view logs & reports
End
Metadata
Release files for xiaoli-autotest-pytest 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xiaoli_autotest_pytest-1.0.1.tar.gz | 5.2 kB | Without provenance | Details for xiaoli_autotest_pytest-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xiaoli_autotest_pytest-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for xiaoli_autotest_pytest-1.0.1-py3-none-any.whl |
Total release size: 9.9 kB
Release files / xiaoli_autotest_pytest-1.0.1.tar.gz
| Download URL | xiaoli_autotest_pytest-1.0.1.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a547c365acda18a947e7300504ae64fed5ff6332a3395f6d925c706e20fa17a0
|
|
BLAKE2b-256 checksum How to use checksums |
de031cb3ffb00721955a7db4f894965ba41c8d5a795ce35c9f0fad9a3cff5dc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.7
|
Release files / xiaoli_autotest_pytest-1.0.1-py3-none-any.whl
| Download URL | xiaoli_autotest_pytest-1.0.1-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
189b31c96f559da5b2dac2513f0a0a92a50a8f41239874c9498fddac4ad86f3f
|
|
BLAKE2b-256 checksum How to use checksums |
e82143733e8c4a41ce3d7dfaf4d351261056b2026bad2915e83b6e4e4f731cb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.7
|
Security for xiaoli-autotest-pytest 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.