I have a requirement to implement a test suite for multiple functions. I am trying to figure out best practices to leverage existing pytest design pattern.
- There are 2-3 common test cases for all the functions
- Each function require different presetup condition
My current design :
/utils
logic.py
/tests
Test_Regression.py
Sedan/
Test_Sedan.py
SUV/
Test_SUV.py
Hatchback/
Test_Hatchback.py
/config
Configuration.py
Current folder structure
Regression.py : This class holds common testcases
Test_SUV.py : This class inherits Test_Regression class test cases and has SUV specific test cases
Utils : This folder stores the program logic
is this a good design practice for a test suite to have class inheritance
class Regression:
@pytest.parameterize(x, utils.logic_func())
@pytest.mark.testengine
def test_engine(x,self):
#validates logic
assert x == 0
@pytest.parameterize(y, utils.logic_func())
@pytest.mark.testheadlight
def test_headlight(y,self):
#validates logic
assert y == 0
class Test_SUV(Test_Regression):
def get_engine_values():
# calls program logic
return x
.
.
.
.
Or is there a better way to structure these test cases.