← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #676481]: There's some way to "force error" or "failure" for XMLTestRunner?

 

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

Description changed to:
Hi. Good evening for everyone.

I'm working with Sikuli + XMLTestRunner on a larger task. In one part of
the code that I write on Sikule IDE, I have an IF, and, inside this if I
want to "force" an error or failure, because I want to the the info of
fail in XMLTestRunner.

I have been trying for 12 hours diferents kinds of codes or style of
codes and nothing work's fine.

I see this page http://doc.sikuli.org/faq/020-unit-test.html where they
talk about  junit.framework.TestCase, and, inside this framework I find
a class named "TestResult" with methods addError and addFailure that
will be work a lot fine for me, but I don't undestant how to "declare"
it in my code.

Let's take a look about my code: 
class C1Cars(unittest.TestCase):
    def C1_CT1Ford(self):
        setFindFailedHandler(handler)
        wait(Pattern("1541773517913.png").similar(0.63),60000)
        find("1543577993389.png") #this pic will not be found, and the handler will be called.
        click("1541772230536.png") 
        click("1541772263254.png")
        type(' sikulix')
        wait("1541772336503.png",100) 
        if(handlerchamado>0): #inside handler definition, we increase this var
            ### HERE I WANT TO RETURN AN ERROR ####
            ### SO THE METHOD WILL BE THERE ####
        else:            
            ### HERE THE TEST WILL END WITHOUT RETURN ANY ERROR

def suite():
    suite = unittest.TestSuite()
    
  
    suite.addTest(C1Cars('C1_CT1Ford'))
    #suite.addTest(TestDemo('testB'))

    return suite


Someone can help me?

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