Pytest - there were no tests

I use pytest and selenium. When I try to 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() 

Message displayed: tests failed in 0.84 seconds.

Can someone help me complete this simple test?

+9
source share
3 answers

According to pytest tests , your class should start with Test which will be automatically selected by the test detection engine. TestRegisterNewInstructor this name it TestRegisterNewInstructor .

Or subclasses of unittest.TestCase :

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

Also keep in mind that the .py test script itself should start with test_ in its file name.

+15
source

Did you complete the class itself?
I do not see in this code that you are showing that you are calling a class or definitions to run.
For example, in python, you run a class or definition like this:

 class Hello(): # __init__ is a definition runs itself. def __init__(self): print('Hello there') # Call another definition. self.andBye() # This definition should be calles in order to be executed. def andBye(self): print('Goodbye') # Run class Hello() 
0
source

try adding @classmethod at the top of setUP and tearDown.

0
source

Source: https://habr.com/ru/post/1238670/


All Articles