← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #239106]: Extructure of UnitTest

 

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

    Status: Needs information => Answered

RaiMan proposed the following answer:
besides not having divided the stuff into separate .py, this does what
it should:

import unittest

class TestInit(unittest.TestCase):
    def setUp(self):
        print "setup"

    def tearDown(self):
        print "teardown"

class Test1(TestInit):
    def test_11(self):
        print "test11"
        assert True

    def test_12(self):
        print "test12"
        assert True
    
    def test_13(self):
        print "test13"
        assert True

class Test2(TestInit):
    def test_21(self):
        print "test21"
        assert True

    def test_22(self):
        print "test22"
        assert True
    
    def test_32(self):
        print "test23"
        assert True

suite = unittest.TestSuite((
        unittest.TestLoader().loadTestsFromTestCase(Test1),
        unittest.TestLoader().loadTestsFromTestCase(Test2),
        ))
unittest.TextTestRunner().run(suite)

--- output
......
----------------------------------------------------------------------
Ran 6 tests in 0.001s

OK

setup
test11
teardown
setup
test12
teardown
setup
test13
teardown
setup
test21
teardown
setup
test22
teardown
setup
test23
teardown

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