Execute tests from multiple classes with a single output file

Asked by Raza

Hi,

Using Sikuli IDE 1.1.0-Beta 1 here.

Is there a better/smarter way to execute tests from multiple classes that produces a single HTMLTestRunner output file?

I have the following classes with tests in them

#script Class1.sikuli
=================
class myFirstClass(unittest.TestCase):

    def test_Sale1(self):
        print "SALE 01"

    def test_Sale2(self):
        print "SALE 02"

#script Class2.sikuli
=================
class mySecondClass(unittest.TestCase):

    def test_Sale3(self):
        print "SALE 03"

#script Runner.sikuli
=================
from myFirstClass import *
from mySecondClass import *

suite = unittest.TestLoader().loadTestsFromTestCase(myFirstClass)
runner.run(suite)

suite = unittest.TestLoader().loadTestsFromTestCase(mySecondClass )
runner.run(suite)

I have tried the above code which produces a single HTML output file but the links for expanding the results of the tests don't work in them... they keep going to the results of the tests from myFirstClass.

Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Raza
Solved:
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

you have to build one suite (see Python docs), since each test run (runner.run()) produces its own report.

Revision history for this message
Raza (razarf) said :
#2

Thanks RaiMan,

Updated Runner.sikuli to this and it worked like a treat :)

#script Runner.sikuli
=================

runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title='POS', description='POS Sale')

loader = unittest.TestLoader()
suite1 = loader.loadTestsFromModule(Class1)
suite2 = loader.loadTestsFromModule(Class2)

all_suite = unittest.TestSuite([suite1,suite2])
runner.run(all_suite)