← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #212171]: tearDown not called when calling exit() in a unit test

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
If it was a unit test that makes sense, it should have looked this way:

def setUp(self):
    print "Setting up..."
    #some set-up code goes here

def tearDown(self):
    print "Tearing Down..."
    #some code for tearing down goes here

def testSomething(self):
    assert exists("SomeImage.png")

and if you want to produce a message in the test case:

def setUp(self):
    print "Setting up..."
    #some set-up code goes here

def tearDown(self):
    print "Tearing Down..."
    #some code for tearing down goes here

def testSomething(self):
    if not exists("SomeImage.png"):
        print "Verification failed for SomeImage"
        assert False
   else: assert true 

the assert calls are what drives the workflow of a unit test and leads
to the pass/fail/error stats:

setUp
test1
tearDown 
setUp
test2
tearDown 
setUp
test3
tearDown 
setUp
test4
tearDown 
....

But if you are really interested in unit testing: faq 1804

If your primary interest is NOT unit testing, just forget this and make
normal scripts, that are run normally.

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