# -*- encoding:utf-8 -*-
import unittest2
from HTMLTestRunner import HTMLTestRunner
from selenium import webdriver
# create TestClass and inherit from unittest2.TestCase
class Baidu(unittest2.TestCase):
def test_baidu(self):
driver = webdriver.Firefox()
driver.get("http://www.baidu.com")
driver.quit()
# Create test unit tester,add testcase by addTest method with format.
tester = unittest2.TestSuite()
tester.addTest(Baidu("test_baidu")) # format:addTest(TestClassName("methodName"))
with open('./result3.html', "w") as f:
# create HTMLTestRunner object and set params: stram= opened file, title and desc.
runner = HTMLTestRunner.HTMLTestRunner(stream=f, title="百度测试", description="ceshi")
# run test.
runner.run(tester)