← Back to team overview

sikuli-driver team mailing list archive

[Question #239106]: Extructure of UnitTest

 

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

Hi,

Are any of you in this forum that know how to structure UnitTest, testsuite and setup/tearDown in the correct way?

If I create the following structure:

allTest.py
def suite():
  return unittest.TestSuite([
                              unittest.TestLoader().loadTestsFromTestCase(A_test.ATestCase)                           
                            , unittest.TestLoader().loadTestsFromTestCase(B_test.BTestCase)
                            , unittest.TestLoader().loadTestsFromTestCase(C_test.CTestCase)                         
                            ])
if __name__ == '__main__':
  unittest.TextTestRunner().run(suite())

A_test.py
class ATestCase(TestInit):
        def test_build_uri_abs(self):            

        def test_build_uri_rel(self):              

        def test_build_uri_rel_slashless(self):

B_test.py
classBTestCase(TestInit):
        def test_build_uri_abs(self):              

        def test_build_uri_rel(self):               

        def test_build_uri_rel_slashless(self):

C_test.py
class CTestCase(TestInit):
        def test_build_uri_abs(self):              

        def test_build_uri_rel(self):               

        def test_build_uri_rel_slashless(self):              

Init.py
class TestInit(unittest.TestCase):    
     
    def setUp(self):
        global ffApp 
        ffLoc = r'C:\Program\Mozilla Firefox\firefox.exe'
        ffTitle = "Mozilla Firefox"
        ffApp = App(ffTitle)  # app object "containing" all FF windows
        if not ffApp.window():
            print("open firefox..") 
            App(ffLoc).focus()  # opens FF
            wait(4)
        ffApp.focus()       
        print("type zaci url..")  
        type('l', KEY_CTRL)
        paste('https://localhost/index.php')
        type(Key.ENTER)
        wait("1381231580670.png", 20)
        with Region(find("1381231618344.png")):
            doubleClick("1381231634958.png")
            type("hudson")
            wait(2)
            doubleClick("1381231649319.png")
            type("hudson1")
            wait(2)
            click("1381231658482.png")         
        wait("1381231705529.png", 10)     
 
    def tearDown(self):
        print("Close Firefox")
        click("Loggaut.png")
        wait(2)            
        ffApp.close()
        wait(5)

Any comment and feedback will appreciated.

//RB


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