pytest not discovering test in pyDev

风流意气都作罢 提交于 2019-12-13 02:57:19

问题


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...

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()

get results as...

what dose

imported unittest before running pytest.main

error means?

why can't it discover test?

collected 0 items

why are methods run only when there is error?


回答1:


After a long search and trial and error found the culprit. You should name class Test_*..

T in UPPER CASE for Class

t in lower case for methods...

though tests are running as supposed, the error remains...



来源:https://stackoverflow.com/questions/49642618/pytest-not-discovering-test-in-pydev

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!