python - How to control test case run through an excel sheet? -


my question design problem. using python + selenium automation. pyunit unit framework used. have sheet in excel have 2 columns- testcaseid , run. testcaseid have testcase id in , run have either y or n signifying whether test case should runnable or not. trying read particular test case id sheet , see have it's run value, y or n. if y, test case executed unit framework else not run.

here excerpt of test case have written:

`class test_id_94017(unittest.testcase):

ex = excel() def setup(self):     self.ex.setupasheetinexcel('select_test_cases_to_run')     if self.ex.gettestcaserunstatusfromexcel("94017") == "y":         self.driver = browser().createbrowserdriver()         self.driver.maximize_window()         self.driver.implicitly_wait(15)         self.ex.setupasheetinexcel('login')     else:         return  def test_ccpd_regression001_per_custom_check(self):     //do 

the definition gettestcaserunstatusfromexcel(testcaseid) method is:

`def gettestcaserunstatusfromexcel(self, testcaseid):

    i=1     while self.worksheet.cell_value(i,0).value != testcaseid:         i+=1     return self.worksheet.cell_value(i,1).value 

here problems facing:

  1. how should give condition in existing code y, test case executes? should give if condition in setup method test case class have mentioned in code above?

  2. is way in trying iterate on rows in column (of excel sheet) correct until find testcase id , corresponding run value (y or n)?

please help!

i implemented similar design selenium+testng suite. after reading execution flags excel, create testng.xml dynamically , run same xml. testng provides features xml created , executed dynamically. not sure if have similar in pyunit. hope gives ideas.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -