pytest 没有在 pyDev 中发现测试 [英] pytest not discovering test in pyDev
问题描述
我正在尝试使用 pytest 框架构建和运行 (不相关的 selenium) 测试套件.
I'm trying to build and run (selenium which is not relevant) test-suite with pytest framework.
我写了一个简单的测试如下
I wrote a simple test as follows
class test_pqr():
def test_lmn(self):
print("AAAAAAAAAAAAAAAAAAAAA")
assert True
def test_xyz(self):
assert False
x= test_pqr()
x.test_lmn()
当我运行它时我得到了结果......
when I run it I got result...
如果我也运行 xyz ......例如
if I run xyz as well... eg
class test_pqr():
def test_lmn(self):
print("AAAAAAAAAAAAAAAAAAAAA")
assert True
def test_xyz(self):
assert False
x= test_pqr()
x.test_lmn()
x.test_xyz()
获得结果为...
什么剂量
在运行 pytest.main 之前导入 unittest
imported unittest before running pytest.main
错误是什么意思?
为什么它不能发现测试?
why can't it discover test?
已收集 0 件商品
为什么方法只在出现错误时运行?
why are methods run only when there is error?
推荐答案
经过长时间的搜索和反复试验找到了罪魁祸首.您应该将类命名为 Test_*..
After a long search and trial and error found the culprit. You should name class Test_*..
类中大写的 T
t 方法的小写...
虽然测试按预期运行,但错误仍然存在...
though tests are running as supposed, the error remains...
这篇关于pytest 没有在 pyDev 中发现测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!