[英]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 庫中存在一個命名約定,所有測試都以“test”開頭,這會通知測試運行者哪些方法代表測試。
您必須將“測試”方法更改為“測試”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.