Python Automation Test - Chapter 1: pytest

一、环境准备:下载pytest

1. new a project in PyCharm:

Python Automation Test - Chapter 1: pytest_第1张图片

2. download pytest in terminal

pip install pytest

Python Automation Test - Chapter 1: pytest_第2张图片 

3. go to preferences:

Python Automation Test - Chapter 1: pytest_第3张图片

4. confirm that pytest is working in the terminal:

pytest

Python Automation Test - Chapter 1: pytest_第4张图片

5. new a Python Package & new file:

Python Automation Test - Chapter 1: pytest_第5张图片

Python Automation Test - Chapter 1: pytest_第6张图片

二、实例1

(写一个统计字符串中元音字母个数的功能) 

1. write a function and related test functions:

Python Automation Test - Chapter 1: pytest_第7张图片 

2. run pytest:(单独跑一种测试场景)

Python Automation Test - Chapter 1: pytest_第8张图片

3. run test_ch1.py:(跑整个py文件)

pytest tests/test_ch1.py

Python Automation Test - Chapter 1: pytest_第9张图片 

 

 

你可能感兴趣的:(python)