pytest allure——pytest环境配置搭建 (2)

安装pytest测试框架

#安装
pip install -U pytest
#查看安装版本
pytest --version
创建test_sample.py,内容如下
def func(x):
    return x + 1


def test_answer():
    assert func(3) == 5

执行pytest,可以查看已经执行成功。

工作原理:pytest将运行在当前目录及其子目录中所有格式为 test_ *.py * _test.py 的文件。 它遵循标准的测试发现规则。

创建test_class.py文件,并在当前目录执行 pytest -q test_class.py   (q = "quiet”)
class TestClass:
    def test_one(self):
        x = "this"
        assert "h" in x

    def test_two(self):
        x = "hello"
        assert hasattr(x, "check")

 第三篇:pytest + allure 结合使用展示图表结果(3)

posted @ 2020-04-23 19:13  白灰  阅读(114)  评论(0)    收藏  举报