sikuli-driver team mailing list archive
-
sikuli-driver team
-
Mailing list archive
-
Message #47595
Re: [Question #670579]: Separating identical test ideas needed.
Question #670579 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/670579
RaiMan proposed the following answer:
--- Setup and TearDown methods could be used to run some actions before
and after the actual test, I can see how I can use them but still don't
have idea the way I should code the test to run multiple times with
different input parameters, should I use some kind of loop or it's
something completely different?
Since I do not know your final intention about becoming some expert with
unit-testing with all its aspects (data-driven, fixtures, ...), this
would be a tailored approach for your specific situation.
Be aware: to keep it simple some statements are "pseudocode" ;-)
import unittest
import HTMLTestRunner # because it makes nice reports
from testLogic import innerTest # your test function to be repeated
class MyTest(unittest.TestCase):
def setUp(self):
print "MyTest: setUp"
global parm1, parm2, ...
# somehow fill parmX with a set of values for one test run
# here you might decide to stop the outer loop using system exit
def testToBeRepeated(self):
print "something to show up in the report"
whatEver = innerTest(parm1, parm2, ...)
assert whatEver
def tearDown(self):
print "MyTest: tearDown"
# here you might do something
testReport = file(os.path.join(getParentPath(), 'testReport.html'), 'a')
# each run will append its report
testSuite = unittest.TestLoader().loadTestsFromTestCase(MyTest)
runner = HTMLTestRunner.HTMLTestRunner(stream = testReport)
# simply repeat the testrun until it is killed from inside
while True:
runner.run(testSuite)
--
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.