一、环境准备:下载pytest
1. new a project in PyCharm:
2. download pytest in terminal
pip install pytest
3. go to preferences:
4. confirm that pytest is working in the terminal:
pytest
5. new a Python Package & new file:
二、实例1
(写一个统计字符串中元音字母个数的功能)
1. write a function and related test functions:
2. run pytest:(单独跑一种测试场景)
3. run test_ch1.py:(跑整个py文件)
pytest tests/test_ch1.py