I have a scenario where there are 1000's of test cases in excel.
Is there a way to parameterize the test so that all the test cases run?
I have used pandas and I am getting all the test cases while iterating through:
def getCases():
excel_file = 'path of excel'
result = pd.read_excel(excel_file)
count_row = result.shape[0]
for i in range(count_row):
r = result.iloc[i]
return [r]
Each row in the excel table is a test case and the result returned is in the form of dictionary, which I want to pass as input to my test case.
I use the following fixture to pass these parameters to my test functions:
@pytest.fixture(params=PWC.getCases())
def getData(self, request):
return request.param
The problem is that after the first iteration, it is not reaching this code
and my test case does not return to the getCases() function.
How do I customize the params in pytest fixture so that I will be able to run all the cases?
Will I be able to pass a range inside getCases as parameter?
yieldinstead ofreturn. Also, I'm not sure why you are making an array of the result - is this needed?