当前位置:  开发笔记 > 编程语言 > 正文

Pytest - 没有测试

如何解决《Pytest-没有测试》经验,为你挑选了1个好方法。

我正在使用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秒内运行

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



1> alecxe..:

根据pytest测试约定,您的类应该首先Test由测试发现机制自动选取.TestRegisterNewInstructor改为称呼它.

或者,子类化unittest.TestCase:

import unittest

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

还要记住.py测试脚本本身必须test_以其文件名开头.

推荐阅读
ERIK又
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有