Sikuli xmlrunner/htmlrunner with try catch in test cases

Asked by stewazy on 2017-04-07

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')


    def tearDown(self):
        file = open("C:\\Sikuli\\log.log", 'a')

    def myTest(self):
            var = traceback.format_exc()
            file = open("C:\\Sikuli\\log.log", 'a')

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')


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 :)

Question information

English Edit question
Sikuli Edit question
No assignee Edit question
Last query:
Last reply:
Launchpad Janitor (janitor) said : #1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.