1.在终端用pip install安装pytest和pytest-html。
2.写用例。参考如下:
class TestClass():
def test_one(self):
x = "this"
assert "h" in x
def test_two(self):
x = "hello"
assert x == "hi"
def test_three(self):
x = "world"
assert x != "worl"
3.在用例所在的文件夹打开终端,输入py.test test_class.py --html=./report.html。结果如下: