Having issue using Htmltestrunner and unittest in Sikuli IDE 1.1.3

Asked by Ali Ahmed on 2020-12-31

I am getting this error message when I try to run test. I am pretty with using Sikuli and python for testing. I would appreciate the help. Here is my code. I commentedout some of the lines to see if it would run if I made some adjustments.

Here is the error message I'm getting:

[error] Error caused by: Traceback (most recent call last): File "C:\SikuliX\TestHtmlRunner.sikuli\TestHtmlRunner.py", line 57, in <module> unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='C:\\Sikuli')) File "C:\Users\ali.ahmed\AppData\Roaming\Sikulix\Lib\unittest\main.py", line 95, in __init__ self.runTests() File "C:\Users\ali.ahmed\AppData\Roaming\Sikulix\Lib\unittest\main.py", line 234, in runTests sys.exit(not self.result.wasSuccessful()) SystemExit: False

Code Below:

import os
import sys
import time
import shutil

dir="C:\\SikuliX"

if not dir in sys.path: sys.path.append(dir)

#from XMLTestRunner1 import *

#import xmlrunner
#reload(xmlrunner)

#from xmlrunner import *

import unittest
reload(unittest)

import utils
reload(utils)

#fp=file(os.path.join(dir,"UI_TestReport.html"),"wb")

import HTMLTestRunner
reload(HTMLTestRunner)

Debug.on(0);

class Test(unittest.TestCase):
    def setUp(self):
        utils.openApplication()
        Debug.info('Setup Called')

if __name__ == '__main__':
    unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='C:\\Sikuli'))
#suite= unittest.TestLoader().loadTestFromTestCase(Test)

#runner= HTMLTestRunner.HTMLTestRunner(stream =fp,verbosity=3,dirTestScreenshots=dir)
#runner.run(suite)

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Last query:
2021-01-04
Last reply:
2021-01-06
RaiMan (raimund-hocke) said : #1

SikuliX 1.1.3 is no longer supported. Please use 2.0.4 according to the download page.

Make some basic tests with minimal scripts and then move into more complex constructs.

reload() is generally not needed for any Python module, that is not changed, while SikuliX IDE is running.
even for imported scripts, that are open and changed in the same IDE session, with 2.0.4 even there is no reload() necessary (done internally automatically.

like so:

import HTMLTestRunner
import unittest

class MyTest(unittest.TestCase):
    def test1(self):
        assert True
    def test2(self):
        assert False

suite= unittest.TestLoader().loadTestFromTestCase(MyTest)

runner= HTMLTestRunner.HTMLTestRunner()
runner.run(suite)

If this works, go on with your ideas.

Ali Ahmed (ali13xii) said : #2

I'm using the 2.0.4 and I tried to code above that you written but I'm getting an error.

[error] script [ Testcode ] stopped with error in line 10
[error] AttributeError ( 'TestLoader' object has no attribute 'loadTestFromTestCase' )
[error] --- Traceback --- error source first
line: module ( function ) statement
10: main ( <module> ) suite= unittest.TestLoader().loadTestFromTestCase(MyTest)
[error] --- Traceback --- end --------------

Ali Ahmed (ali13xii) said : #3

And I tried it with my original code and I'm getting the following error:

[error] script [ Testtest1 ] stopped with error in line 34
[error] NameError ( name 'HtmlTestRunner' is not defined )
[error] --- Traceback --- error source first
line: module ( function ) statement
34: main ( <module> ) unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='C:\\Sikuli'))
[error] --- Traceback --- end --------------

RaiMan (raimund-hocke) said : #4

there is a new question on that issue

Ali Ahmed (ali13xii) said : #5

Ok i found old question, that helped me resolve issue