在 运行 测试套件上:运行测试套件显示测试已通过通知但显示 "Empty Suite"

On Running the test suite: Runs the test suite shows test passed Notification but displays "Empty Suite"

这是我的代码,但它显示没有找到测试,并打印 Empty Suite

import unittest
import time
from selenium import webdriver


class LoginTest(unittest.TestCase):
    driver = webdriver.Chrome(executable_path="C:\Users\win\Desktop\chromedriver.exe")

    @classmethod
    def setUpClass(cls):
        cls.driver = webdriver.Chrome(executable_path="C:\Users\win\Desktop\chromedriver.exe")
        cls.driver.implicitly_wait(10)

    def Test(self):
        self.driver.get("https://opensource-demo.orangehrmlive.com/")
        self.driver.find_element_by_id("txtPassword").send_keys("admin123")
        self.driver.find_element_by_id("txtUsername").send_keys("Admin")
        self.driver.find_element_by_id("btnLogin").click()
        time.sleep(2)

    @classmethod
    def tearDownClass(cls):
        cls.driver.close()
        cls.driver.quit()
        print("Test Complete")


if __name__ == '__main__':
    unittest.main()

我写了这段代码,但在 运行 我的测试套件上它显示如下:

Testing started at 2:47 PM ...
C:\PycharmProject\OrangeHRM\venv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pycharm\_jb_unittest_runner.py" --target LoginTest.LoginTest
Launching unittests with arguments python -m unittest LoginTest.LoginTest in C:\PycharmProject\OrangeHRM\ScriptsDemo\Tests



Ran 0 tests in 0.000s

OK

Process finished with exit code 0

No Tests were found

Empty suite

unittest library 中存在所有测试都以 'test' 开头的命名约定,这会告知测试运行器哪些方法代表测试。

您必须将 'Test' 方法更改为 'test'