天天看点

pytest自动化测试框架

安装pytest

在编辑器或者cmd命令窗口输入: <code>pip install pytest</code> 或者 <code>pip install pytest -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com</code>

使用规则:

以test_开头的函数 ;

以test开头的类;

参数 -s   可以看到运行后的结果中多了打印的内容,打印print 调式相关信息

参数 -v   显示运行的测试用例的类名和函数名,显示详细的执行结果

检查点(断言)

pytest中用例的检查点直接用python的assert断言。

assert后面的表达式结果为true,就是检查点通过,结果为false,就是检查点不通过。