← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #670542]: How to use HTMLTestRunner to create a test report

 

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

    Status: Open => Answered

RaiMan proposed the following answer:
This is a tested example:

import unittest
import HTMLTestRunner

testReport = file(os.path.join(getParentPath(), 'testReport.html'), 'wb')
# the report file will be in the same folder as the script
# open with a browser

class MyTest(unittest.TestCase):
  def setUp(self):
    print "MyTest: setUp"
  
  def testA(self):
    print "running testA"
    click("imageA")
    assert exists("imageA2",5)
  
  def testB(self):
    print "running testB"
    click("imageB")
    assert exists("imageB2",5)
  
  def testC(self):
    print "running testC"
    click("imageC")
    assert exists("imageC2",5)
  
  def tearDown(self):
    print "MyTest: tearDown"

testSuite = unittest.TestLoader().loadTestsFromTestCase(MyTest)
runner = HTMLTestRunner.HTMLTestRunner(stream = testReport)
runner.run(testSuite)

Besides copying and pasting other people's code snippets, I recommend to
learn about the Python unittest feature, that is the background on that
HTMLTestRunner works.

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