Rafael Rafael - 23 days ago 9
Python Question

Pytest - no tests ran

Currently I'm using pytest (I'm new with this) and selenium. When I try run my 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()


Is shown the message: no tests ran in 0.84 seconds

Could someone help me run this simple test?

Answer

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.

Or, subclass the unittest.TestCase:

import unittest

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