Pytest-没有运行测试 [英] Pytest - no tests ran

查看:48
本文介绍了Pytest-没有运行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用pytest和硒.当我尝试运行测试脚本时:

I'm using pytest and selenium. When I try run my test script:

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秒内运行

有人可以帮我运行这个简单的测试吗?

Could someone help me run this simple test?

推荐答案

根据 pytest 测试约定,您的类应以 Test 开头,以由测试发现机制自动提取.改名为 TestRegisterNewInstructor .

According to the pytest test conventions, your class should start with Test to be automatically picked up by the test discovery mechanism. Call it TestRegisterNewInstructor instead.

或者,将 unittest.TestCase 子类化:

import unittest

class RegisterNewInstructor(unittest.TestCase):
    # ...

还请记住,.py测试脚本本身必须以其文件名中的 test _ 开头.

Also keep in mind that the .py test script itself must begin with test_ in its filename.

这篇关于Pytest-没有运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆