我正在使用pytest和selenium.当我尝试运行我的测试脚本时:
import pytest from selenium import webdriver from pages import * from locators import * from selenium.webdriver.common.by import By import time class RegisterNewInstructor: def setup_class(cls): cls.driver = webdriver.Firefox() cls.driver.get("http://mytest.com") def test_01_clickBecomeTopButtom(self): page = HomePage(self.driver) page.click_become_top_button() self.assertTrue(page.check_instructor_form_page_loaded()) def teardown_class(cls): cls.driver.close()
显示的消息是:没有测试在0.84秒内运行
有人可以帮助我进行这个简单的测试吗?
根据pytest
测试约定,您的类应该首先Test
由测试发现机制自动选取.TestRegisterNewInstructor
改为称呼它.
或者,子类化unittest.TestCase
:
import unittest class RegisterNewInstructor(unittest.TestCase): # ...
还要记住.py测试脚本本身必须test_
以其文件名开头.