← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #663899]: HTML reports shows pass even if the test Fails in Sikuli

 

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

RaiMan proposed the following answer:
Generally you should think about using RobotFrameWork. if it is about
testing with SikuliX.

There is a wrapping library:
https://github.com/rainmanwy/robotframework-SikuliLibrary

If you want to stick with your setup:
Use the SikuliX user logging - is much simpler:
http://sikulix-2014.readthedocs.io/en/latest/scripting.html#writing-and-redirecting-log-and-debug-messages

If I would do it (no logging):

setUp/tearDown should handle any bad situation and exit if it does not
make sense to continue

   def setUp(self):
       TD5 = os.popen(r"C:\Tools\TD5\start_td5_adas_net.lnk")
       if not exists("TD5_ready.png", 30):
            print'Unable to launch TD5'
            exit(1) # makes no sense to continue

    def tearDown(self):
        if exists("TD5_ready.png"):
            click(Pattern("TD5_terminate.png").targetOffset(19,-29))
            if not waitVanish("TD5_ready.png", 30):
                print'Unable to stop TD5'
                exit(1) # makes no sense to continue
        else:
                print'TD5 not visible'
                exit(1) # makes no sense to continue
       
.... only one aspect per test

    def test_ClickNewProjectButton(self):
 #### see below          
          if exists("TD5_ready.png"): ### not needed, setup has done it or exited!
                click(Pattern("TD5_newProjectButton.png").similar(0.80).targetOffset(-9,1))
                if exists(Pattern("1517330266749.png").similar(0.90), 5):
                    #### click("1517330523887.png") does not make sense here
                    assert True
                else:
                    assert False
#### this should never happen, see setup
            else:
                logger.error("Unable to click on new button in toolbar")

... so this would be my test:
    def test_ClickNewProjectButton(self):
        if exists(Pattern("TD5_newProjectButton").similar(0.80).targetOffset(-9,1))
            click()
            assert exists(Pattern("TD5_newProjectButtonResult").similar(0.90), 5), "TD5_newProjectButtonResult not there within 5 seconds)
       else:
           assert False, "TD5_newProjectButton not seen"

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.