我是单元测试的新手,“我正在尝试在Eclipse上运行pytest
”。我已经找了好几个小时了,似乎找不到问题所在。我在玩https://pytest.org网站上的简单示例。我的问题是pytest
不能在Eclipse上运行。我可以使用命令提示符来进行测试,但我更希望结果显示在控制台窗口上。在
我试过但没用的东西
PyUnit
test runner设置为Py.test
runner(而不是默认的Pydev测试运行器)在本例中,我得到以下错误消息
usage: runfiles.py [options] [file_or_dir] [file_or_dir] [...] runfiles.py: error: unrecognized arguments: --verbosity inifile: None rootdir: C:\peepee\pytest\testing
我试图从http://pytest.org网站测试的简单代码
def func(x):
return x + 1
def test_answer():
assert func(3) == 5
通过cmd而不是Eclipse。在
请帮帮我,因为我正浪费时间想办法弄清楚。提前谢谢
找到了另一个选择。只需使用PyCharm IDE,它使pytest非常容易运行。确保在运行任何测试之前执行以下配置。在
快乐的日子。现在您已经运行了pytest,结果显示在控制台窗口上
它不适合您,因为您在参数文本字段中留下了“verbosity 0”。我不知道为什么Eclipse不会自动删除它,但是当您更改运行器时,还必须更改参数以反映您首选的测试运行器(在本例中是pytest)。在
对于所有新配置,全局范围内:
或者,如果您愿意,手动为每个新的运行配置
1)从运行菜单打开运行配置
2)右键单击python unittest并选择new以配置新配置
3)在主模块中选择项目和,选择包含测试用例的模块。在
4)在arguments选项卡下,选中“override pyunit preferences for this launch”。在
5)选择Py.测试从下拉菜单中选择跑步者。在
6)类型tb=short和capture=no(可以根据用户偏好更改值)
7)单击“应用”,然后单击“运行”。在
相关问题 更多 >
编程相关推荐