← Back to team overview

sikuli-driver team mailing list archive

[Question #614515]: Sikuli xmlrunner/htmlrunner with try catch in test cases

 

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

Hello everyone, I want to aplogize to Raiman, I'm openning a new question related to xmlrunner/html runner.

First off I'm using this xml runner.I have a problem logging error in a file log.log and at the same time getting a correct xmlreport.xml report. When I have try to run my suite the logging works flawlessly but the xmlreport generates a positive report every time, regardless if my test fails.

Here is my test setup: 

import unittest
import sys
import logging
import os
import traceback



from sikuli import *


class setUp(unittest.TestCase):
    def setUp(self):
        file = open("C:\\Sikuli\\log.log", 'a')
        file.write('Starting")
        file.close()

        wait(1)
        
    def tearDown(self):
        file = open("C:\\Sikuli\\log.log", 'a')
        file.write('Ending")
        file.close()
 
    def myTest(self):
        try:
            #test
        except:
            var = traceback.format_exc()
            file = open("C:\\Sikuli\\log.log", 'a')
            file.write(var)
            file.close()

Here is my runner setup

import sys
import os

if not helpersPath in sys.path: sys.path.append(helpersPath)
MyTestPath = "C:\\Sikuli\\Mytests"
if not MyTestPath in sys.path: sys.path.append(MyTestPath )


from xmlrunner import *
from sikuli.Sikuli import *
from MyTest import *

#setup - clean log file
fileName = "C:\\Sikuli\\log.log"
f = open(fileName,'w')
f.truncate()
f.close()


suite=unittest.TestLoader().loadTestsFromTestCase(myTest)



result = XMLTestRunner(file("C:\\Sikuli\\test-results.xml", "w")).run(suite)

Is there any way that I can get the error in my log file and at the same time to generate a working xmlresult file at the end ? Thank you in advance and especially for your patience with me :) I a python newbie :)



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