Ejemplo n.º 1
0
def run(method, test=None):
    if method == 'all':
        test_dir = './testcase'
        suite = unittest.defaultTestLoader.discover(start_dir=test_dir,
                                                    pattern='test_1*.py')

        now = time.strftime('%Y-%m-%d_%H_%M_%S')
        reportname = os.path.join(globalparam.report_path,
                                  'TestResult' + now + '.html')
        with open(reportname, 'wb') as f:
            runner = HTMLTestRunner_ui.HTMLTestRunner(
                stream=f,
                title='测试报告',
            )
            runner.run(suite)
        time.sleep(3)
        # 发送邮件
        # MongoModel().delete_customer('13800138011')
        mail = sendmail.SendMail()
        mail.send()
    if method == 'one':
        suit = unittest.TestSuite()
        suit.addTest(test)  # 把这个类中需要执行的测试用例加进去,有多条再加即可
        runner = unittest.TextTestRunner()
        runner.run(suit)
Ejemplo n.º 2
0
def run():
    test_dir = './testcase'
    suite = unittest.defaultTestLoader.discover(start_dir=test_dir,
                                                pattern='test*.py')

    now = time.strftime('%Y-%m-%d_%H_%M_%S')
    reportname = globalparam.report_path + '\\' + 'TestResult' + now + '.html'
    with open(reportname, 'wb') as f:
        runner = HTMLTestRunner.HTMLTestRunner(
            stream=f, title=u'测试报告', description='Test the import testcase')
        runner.run(suite)
    time.sleep(3)
    #发送邮件
    mail = sendmail.SendMail()
    mail.send()
Ejemplo n.º 3
0
def run():
    test_dir = './testcase'
    suite = unittest.defaultTestLoader.discover(start_dir=test_dir,
                                                pattern='test*.py')

    now = time.strftime('%Y-%m-%d_%H-%M-%S')
    reportname = globalparam.report_path + '//' + 'TestReport_' + now + '.html'
    with open(reportname, 'wb') as f:
        runner = HTMLTestRunner_CN.HTMLTestRunner(
            stream=f,
            title='GitHub平台测试报告_{0}'.format(now),
            description='详细测试用例结果'
            '环境名称:{0}。 URL:{1}'.format(globalparam.Env_Name,
                                       globalparam.Env_Url),
            verbosity=2,
            retry=5,
            save_last_try=True)
        runner.run(suite)
    time.sleep(3)
    # 发送邮件
    mail = sendmail.SendMail()
    mail.send()
Ejemplo n.º 4
0
def run(method, test=None):
    if method == 'all':
        test_dir = './testcase'
        suite = unittest.defaultTestLoader.discover(start_dir=test_dir,
                                                    pattern='test*.py')
        now = time.strftime('%Y-%m-%d_%H_%M_%S')
        reportname = os.path.join(globalparam.report_path,
                                  'TestResult' + now + '.html')
        with open(reportname, 'wb') as f:
            runner = HTMLTestRunner.HTMLTestRunner(stream=f,
                                                   title='UI自动化测试报告',
                                                   description='输出如下报告')
            runner.run(suite)
        # 等待三秒,发送邮件
        time.sleep(3)
        mail = sendmail.SendMail()
        mail.send()

    if method == 'one':
        suit = unittest.TestSuite()
        suit.addTest(test)  # 把这个类中需要执行的测试用例加进去,有多条再加即可
        runner = unittest.TextTestRunner()
        runner.run(suit)
Ejemplo n.º 5
0
def run(method, test=None):
	if method == 'all':
		test_dir = "./testcase"
		suite = unittest.defaultTestLoader.discover(start_dir=test_dir, pattern='*.py')
		
		now = time.strftime('%Y-%m-%d_%H_%M_%S')
		reportname = globalparam.report_path + '\\' + 'TestResult' + now + '.html'
		with open(reportname, 'wb') as f:
			runner = HTMLTestRunner.HTMLTestRunner(
				stream=f,
				title='测试报告',
				description='Test the import testcase'
			)
			runner.run(suite)
		time.sleep(3)
		# 发送邮件
		mail = sendmail.SendMail()
		# mail.send()
	if method == 'one':
		suit = unittest.TestSuite()
		suit.addTest(test)  # 把这个类中需要执行的测试用例加进去,有多条再加即可
		runner = unittest.TextTestRunner()
		runner.run(suit)
Ejemplo n.º 6
0
def run():
    test_dir = './testcase'
    suite = unittest.defaultTestLoader.discover(start_dir=test_dir,
                                                pattern='test*.py')

    now = time.strftime('%Y-%m-%d_%H_%M_%S')
    reportname = globalparam.report_path + '\\' + 'TestResult' + now + '.html'
    # with open(reportname,'wb') as f:
    #     runner = HTMLTestRunner.HTMLTestRunner(
    #         stream=f,
    #         title='测试报告',
    #         description='Test the import testcase'
    #     )
    #     runner.run(suite)

    result = BeautifulReport(suite)
    result.report(filename="测试报告",
                  description="Test the import testcase",
                  log_path=reportname)

    time.sleep(3)
    # 发送邮件
    mail = sendmail.SendMail()
    mail.send()
Ejemplo n.º 7
0
def sendMail():
    mail = sendmail.SendMail()
    mail.send()