How to create test suite at runtime based on excel params

Asked by Nidhi Bhushan on 2018-08-31

Please guide me. I am developing test framework using sikuli with Jython to test my desktop based app. I am using HTMLTestRunner (RaiMan's) for reporting. I have an excel file having names of features which I want to test at runtime. If there is '1' present in column next to it, then I want to add it to test suite (otherwise not). How can I do this dynamic addition of test cases to test suite?
Below is my driver script.

####TestDriver.py####

from sikuli import*
import HTMLTestRunner # needed here
reload(HTMLTestRunner)
import unittest
import os,sys

RootFolder = "C:\\Users\\nbhushan\\Desktop\\SikuliFramework_PRE2019"

if not RootFolder in sys.path:
    sys.path.append(RootFolder)

import Effects

print "Starting execution of UI tests for PRE application."

workbook = xlrd.open_workbook(RootFolder+"\\TestData\\" + "PRE_Test_Execution_Data.xls")
worksheet = workbook.sheet_by_index(0)

testcase_list = []
for row in range(worksheet.nrows):
    area_flag = worksheet.cell(row, 3).value
    if area_flag == 1:
        testcase_list.append(worksheet.cell(row, 1).value)

suite=unittest.TestLoader().loadTestsFromModule(Effects, )
outfile = "C:\\Users\\nbhushan\\Desktop\\SikuliFramework_PRE2019\\Output\\TestReport.html"
runner = HTMLTestRunner.HTMLTestRunner(stream=outfile, title='Xbox Test Report', description='This is a demo' )
runner.run(suite)

###end###

Note that I am running 'Effects' module explicitly here, just to make you understand how my driver script looks like. Please suggest changes so that I can run all the test cases which 'testcase_list' variable holds in my script (and not just Effects module) . I dont want to write hard coded repetitive statements to add test case to suite again and again (unless it is my last option).

Question information

Language:
English Edit question
Status:
Answered
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2018-08-31
Last reply:
2018-08-31
RaiMan (raimund-hocke) said : #1

please look into the features of unittest.
There are many different options how to say which tests from class/module should be added to the suite.

Can you help with this problem?

Provide an answer of your own, or ask Nidhi Bhushan for more information if necessary.

To post a message you must log in.