Python 如何为pytest创建HTML报告?
我已经使用pytest框架在eclipse中创建了一个项目Python 如何为pytest创建HTML报告?,python,pytest,pytest-html,Python,Pytest,Pytest Html,我已经使用pytest框架在eclipse中创建了一个项目 class TestClass(object): def test_one(self): x = "this" assert 'h' in x def test_two(self): x = "hello" assert hasattr(x, 'check') 现在,我想为我的项目创建一个html报告。我已完成以下操作: 安装了html插件 在conf
class TestClass(object):
def test_one(self):
x = "this"
assert 'h' in x
def test_two(self):
x = "hello"
assert hasattr(x, 'check')
现在,我想为我的项目创建一个html报告。我已完成以下操作:
- 安装了html插件
- 在conftest.py模块中编写以下代码
> ============================= test session starts ============================= platform win32 -- Python 3.6.5, pytest-3.6.0, py-1.5.3, pluggy-0.6.0 rootdir: D:\Eclipse1\TFCProject,
> inifile: plugins: ordering-0.5, metadata-1.7.0, html-1.19.0 collected
> 2 items
>
> TFCPackage\pycheck.py .F
> [100%]
>
> ================================== FAILURES ===================================
> _____________________________ TestClass.test_two self = <TFCPackage.pycheck.TestClass object at 0x03778AF0>
def test_two(self):
x = "hello"
> assert hasattr(x, 'check')
E AssertionError: assert False
E + where False = hasattr('hello', 'check')
TFCPackage\pycheck.py:13: AssertionError
===================== 1 failed, 1 passed in 0.41 seconds ======================
======================================================================================================平台win32--Python3.6.5,pytest-3.6.0,py-1.5.3,pluggy-0.6.0 rootdir:D:\Eclipse1\tProject,
>inifile:插件:ordering-0.5、metadata-1.7.0、html-1.19.0
>2项
>
>TFCPackage\pycheck.py.F
> [100%]
>
>===================================================故障===================================
>测试类。测试两个自=
def测试二(自身):
x=“你好”
>断言hasattr(x,‘检查’)
断言错误:断言错误
E+其中False=hasattr('hello','check')
TFCPackage\pycheck.py:13:AssertionError
=========================1失败,1在0.41秒内通过======================
请指导我,因为我是pytest的新手如果您想在EclipseIDE中进行测试,您需要更改Eclipse配置
pytest--html=report.html
?谢谢。它通过将“-html=reportname.html”放在参数列表中工作
> ============================= test session starts ============================= platform win32 -- Python 3.6.5, pytest-3.6.0, py-1.5.3, pluggy-0.6.0 rootdir: D:\Eclipse1\TFCProject,
> inifile: plugins: ordering-0.5, metadata-1.7.0, html-1.19.0 collected
> 2 items
>
> TFCPackage\pycheck.py .F
> [100%]
>
> ================================== FAILURES ===================================
> _____________________________ TestClass.test_two self = <TFCPackage.pycheck.TestClass object at 0x03778AF0>
def test_two(self):
x = "hello"
> assert hasattr(x, 'check')
E AssertionError: assert False
E + where False = hasattr('hello', 'check')
TFCPackage\pycheck.py:13: AssertionError
===================== 1 failed, 1 passed in 0.41 seconds ======================