← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #187835]: HTML reporting on multiple suites

 

Question #187835 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/187835

    Status: Open => Answered

RaiMan proposed the following answer:
# --- testScriptA.Sikuli

from sikuli import*
import unittest
# import HTMLTestRunner # to be deleted, not needed here

class UnitTestA(unittest.TestCase):
 def setup(self):
  test code

 def teardown(self):
  test code

 def someTest(self):
  test code

# --- testScriptB.Sikuli

from sikuli import*
import unittest
# import HTMLTestRunner  # to be deleted, not needed here

class UnitTestB(unittest.TestCase):
 def setup(self):
  test code

 def teardown(self):
  test code

 def someTest(self):
  test code

# --- mainTest.sikuli

import unittest

from UnitTestA import *
from UnitTestB import *

import HTMLTestRunner  # needed here

suite=unittest.TestLoader().loadTestsFromTestCase(UnitTestA) # setup new test suite
suite.addTests(unittest.TestLoader().loadTestsFromTestCase(UnitTestB)) # add additional test cases

# unittest.TextTestRunner(verbosity=2).run(suite) # not needed, since
you wantant to run HTMLTestRunner

outfile = open("C:\Report.html", "wb")

runner = HTMLTestRunner.HTMLTestRunner(stream=outfile, title='Xbox Test Report', description='This is a demo' )
runner.run(suite)

outfile.close()

# more comments
--- one test script.sikuli may contain as many unit test classes as needed
(since loading/adding the test cases references the class name, not the module name)

--- normally no need to have more than one suite

--- if you make changes to the test classes, besides the need to save
them, you have to restart the IDE, before running the mainTest again.
Since mainTest should be rather fixed, you could run it from command
line and have the test case script open in IDE as long you are changing
code (only saving needed).

As a workaround, to be able to rerun, you can use:
import some_module
reload(some_module)
from some_module import *
So you can make changes in some_module and rerun the main script without restarting the IDE.

--- with the above sequence of imports, it is sufficient to have all
your scripts in one directory (testScriptA.sikuli, testScriptB.sikuli,
mainTest.sikuli and HTMLTestRunner.py), since with import, the .sikuli
will be searched for in the current directory and after this, this
current directory is in sys.path, so  HTMLTestRunner will be found too.

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.