print "step30.hit back"
	driver.back()
	driver.implicitly_wait(10)
	time.sleep(2)
	result = driver.title
        assert result == 'FastPass | Entitlements - Active managed entitlements for site - Default sort by order date',"The page did not be opened correct"          
	
	print "\n"        
        print "Test Case end with successfully!"    
        
    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)
        


if __name__ == '__main__':
    now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
    testunit=unittest.TestSuite()
    testunit.addTest(FastPass_Agile("test_Case_SoftwareSubscription_VerifyLinks05"))
    filename="C:\LM_IBM_WORK\LM_WORK\FastPass\FastPass_Agile\\result\\"+now+" FastPass_Test_Case_SoftwareSubscription_VerifyLinks05.html"
    fp=file(filename,'wb')
    runner = HTMLTestRunner.HTMLTestRunner(stream=fp,title='FastPass_Agile Test Case',description='This is SoftwareSubscription_VerifyLinks05 test case')
    runner.run(testunit)




        

Beispiel #2
0
'''
Created on Dec 7, 2017

@author: tarun.walia
'''
import os
import sys
import HTMLTestRunner
from com.flipkart.uitests.HeadphonesList.HeadphonesListTest import HeadphonesListTest

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import unittest
#
# from com.flipkart.uitests.login.LoginTest import LoginTest
# from com.flipkart.uitests.ProductDetail.ProductDetailTest import ProductDetailTest

reportDir = "D:\PWorkSpace1\AutomationECommerce\Reports"
os.path.abspath(reportDir)

# testcase_login = unittest.TestLoader().loadTestsFromTestCase(LoginTest)
# testcase_detail = unittest.TestLoader().loadTestsFromTestCase(ProductDetailTest)
testcase_headphoneListPage = unittest.TestLoader().loadTestsFromTestCase(
    HeadphonesListTest)
test_suite = unittest.TestSuite([testcase_headphoneListPage])
outputFile = open(reportDir + "\Report.html", "w")

runner = HTMLTestRunner.HTMLTestRunner(stream=outputFile,
                                       title='Test Report',
                                       description='FlipKart Test cases')
runner.run(test_suite)
	driver.find_element_by_link_text("7954318").click()
	time.sleep(3)
	result = driver.title
        assert result == 'FastPass | Customers - Customer details' ,"The page did not be opened correct"
        C_screenshots.C_screenshots(self,'C:\LM_IBM_WORK\LM_WORK\FastPass\FastPass_Agile\\result\\image\\','SalesOrder_Dsw13_3_p12')
	time.sleep(3)
	
	print "\n"        
        print "Test Case end with successfully!"    
        
    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)
        


if __name__ == '__main__':
    now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
    testunit=unittest.TestSuite()
    testunit.addTest(FastPass_Agile("test_Case_SalesOrder_Dsw13_3"))
    filename="C:\LM_IBM_WORK\LM_WORK\FastPass\FastPass_Agile\\result\\"+now+" FastPass_Test_Case_SalesOrder_Dsw13_3.html"
    fp=file(filename,'wb')
    runner = HTMLTestRunner.HTMLTestRunner(stream=fp,title='FastPass_Agile Test Case',description='This is SalesOrder_Dsw13_3 test case')
    runner.run(testunit)




        

class cnaidai_BankDepository(unittest.TestCase):
    def start_to_test(self):
        cnaidai_Login.cnaidaiLogin('wz025', 'a1111111', '1111')

    def check_user_state(self):
        state = cnaidai_checkAuthState.check_auth_state()
        print state
        if state != 'allAuthenticated':
            print '未实名认证'

    def check_depository_state(self):
        browser = cnaidai_Login.browser
        try:
            browser.find_element_by_link_text('立即开通').click()
        except:
            return


if __name__ == '__main__':
    f = open('./Logs/' + str(time.strftime('%Y%m%d')) + '.txt', 'a+')
    suite = unittest.TestSuite()
    suite.addTest(cnaidai_BankDepository('start_to_test'))
    suite.addTest(cnaidai_BankDepository('check_user_state'))
    suite.addTest(cnaidai_BankDepository('check_depository_state'))
    htmlFile = './testReport/' + str(time.strftime('%Y%m%d')) + '.html'
    fp = file(htmlFile, 'wb')
    runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
                                           title='银行存管项目',
                                           description='测试报告书')
    runner.run(suite)
    f.close()
Beispiel #5
0
# -*- conding:utr-8 -*-
#@Time  :2018/11/16 21:36
#@Author:GYP测试
#@File  :run.py

import unittest
import HTMLTestRunner
from tools.project_path import *

from tools.http_test import TestHttp
suite = unittest.TestSuite()

loader = unittest.TestLoader()

suite.addTest(loader.loadTestsFromTestCase(TestHttp))

with open(html_repot_path, 'wb') as file:
    runner = HTMLTestRunner.HTMLTestRunner(stream=file,
                                           title='这个是接口自动化的测试报告',
                                           description='我来测试哦!',
                                           tester='GYP')
    runner.run(suite)
Beispiel #6
0
import testloadtest
import unittest
import HTMLTestRunner, os


def createsuit():
    '''创建测试方法'''
    test_unit = unittest.TestSuite()
    test_dir = r"脚本保存路径"
    testlist = unittest.defaultTestLoader.discover(test_dir,
                                                   pattern="test*.py",
                                                   top_level_dir=None)
    for test_suit in testlist:
        for testcase in test_suit:
            test_unit.addTest(testcase)
    return test_unit


with open("result.html", "wb") as file:
    '''生成测试报告'''
    runner = HTMLTestRunner.HTMLTestRunner(stream=file,
                                           title="测试报告",
                                           description="执行用例")
    runner.run(createsuit())
Beispiel #7
0
def creatsuitel():
      testunit=unittest.TestSuite()
#discover 方法定义
      discover=unittest.defaultTestLoader.discover(listaa,
            pattern ='Test_*.py',
            top_level_dir=None)
#discover 方法筛选出来的用例,循环添加到测试套件中
      for test_suite in discover:
            for test_case in test_suite:
                  testunit.addTests(test_case)
                  print testunit
      return testunit

alltestnames = creatsuitel()
now = time.strftime("%Y-%m-%d-%H_%M_%S",time.localtime(time.time()))
filename='D:\\Users\\Administrator\\PycharmProjects\\pdms\\test\\result\\'+now+'result.html'
fp = file(filename, 'wb')
runner =HTMLTestRunner.HTMLTestRunner(
      stream=fp,
      title=u'PDMS系统测试报告',
      description=u'用例执行情况:')

if __name__ == "__main__":
      #执行测试用例
      runner.run(alltestnames)
      fp.close()
      #执行发邮件
      sendreport()
#fp.close()
#放在这里会先发邮件,再生成html文件,造成邮件内容空的
Beispiel #8
0
from testsuit.regist_test import RegistTest
from testsuit.search_test import SerchTest
import unittest
import os
import time

new_path = os.path.dirname(os.path.realpath("."))
report_path = os.path.join(new_path + '\Report')
if not os.path.exists(report_path):
    os.makedirs(report_path)
# print(new_path)
# print(report_path)
suite = unittest.TestSuite()
suite.addTests(unittest.makeSuite(AddbwlTest))
suite.addTests(unittest.makeSuite(SerchTest))
suite.addTests(unittest.makeSuite(OrderTest))
suite.addTests(unittest.makeSuite(ArchiveTest))
suite.addTests(unittest.makeSuite(DeleteTest))
suite.addTests(unittest.makeSuite(RegistTest))
suite.addTests(unittest.makeSuite(ModifyTest))
suite.addTests(unittest.makeSuite(LoginTest))

if __name__ == "__main__":
    html_report = report_path + r'\result.html'
    fp = open(html_report, "wb")
    runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
                                           verbosity=2,
                                           title="测试报告",
                                           description="手机端测试报告情况描述")
    runner.run(suite)
#                 print "Expected Response : ", str_tc_expectedvalue
#         if str_tc_methodname.upper() == "DELETE":
#             deleterequestresult = rest.deleteRequest(self.Host_URL, str_tc_endpointurl, str_tc_requestbody, str_tc_requestheaders, str_tc_expectedstatuscode)
#             if str(deleterequestresult) == str_tc_expectedvalue:
#                 print "DELETE Request Test Case Passed"
#                 print "Actual Response   : ", deleterequestresult
#                 print "Expected Response : ", str_tc_expectedvalue

#     def test_runSuite(self):
#
#         self.test_run_setExecutionType()
#         self.restMethodCall()

#----------------------------------------------------------------------
if __name__ == "__main__":

    #     obj = ExecuteTestSuite()
    #     obj.test_runSuite()
    #     obj.test_run_setExecutionType()
    #     unittest.main()

    suite = unittest.TestLoader().loadTestsFromTestCase(
        ExecuteTestSuite_New)  #replace htmlreportsdemo with your class name
    unittest.TextTestRunner(verbosity=1)
    output = open("results.html", "w")
    runner = HTMLTestRunner.HTMLTestRunner(
        stream=output,
        title='Test Report',
        description='This is for demonstrating HTMLTestResults')
    runner.run(suite)
Beispiel #10
0
import os
import unittest
from tysxunittest import tysxlogin
from tysxunittest import tysxwork
import HTMLTestRunner
# 设置系统的编码格式为utf-8 设置下面这三句的目的是为了在自动化测试报告断言出错的时候能看中文
# import sys
# # 重载sys
# reload(sys)
# # 设置编码格式
# sys.setdefaultencoding("utf-8")

# 初始化suit
suit = unittest.TestSuite()
# 添加测试套件
#suit.addTest(unittest.makeSuite(tysxlogin.TYSX))
suit.addTest(unittest.makeSuite(tysxwork.TYSXwork))

# 设置自动化测试报告的路径
# fileUrl="D:/HtmlTestRunner/tysx.html"

# 报告路径在当前目录下
fileUrl = os.getcwd() + '\\tysx.html'

# 以IO流的形式写入
fl = file(fileUrl, "wb")
runner = HTMLTestRunner.HTMLTestRunner(stream=fl,
                                       title=u"天元数学网",
                                       description=u"详情界面")
runner.run(suit)
Beispiel #11
0
#coding:utf-8
import unittest
import HTMLTestRunner

class AA(unittest.TestCase):
    def setUp(self):
        pass
    def test01(self):
        self.assertEqual(4,6,msg="aa")
    def test02(self):
        self.assertEqual(5,5)
    def test03(self):
        self.assertIn("a","cvb")
    def test04(self):
        self.assertIn("z","zxc")

if __name__=="__main__":
    rongqi = unittest.TestSuite()
    rongqi.addTest(AA("test01"))
    rongqi.addTest(AA("test02"))
    rongqi.addTest(AA("test03"))
    rongqi.addTest(AA("test04"))
    url = "csbg.html"
    fp = file(url,'wb')
    runner = HTMLTestRunner.HTMLTestRunner(
        stream=fp,title=u"报告",description="reort"
    )
    runner.run(rongqi)
Beispiel #12
0
    suite = unittest.TestSuite()

    #apiTestCase.
    '''
    apiTestCase.loop_create_function(['00000004','00000005','00000006'])
    aaa = apiTestCase("test_api_index")
    print dir(apiTestCase)
    '''
    #print apiTestCase.__class__.__name__

    #tests = [apiTestCase("test_api_index","00000004"), apiTestCase("test_show"),apiTestCase("test_row"),apiTestCase("test_api_index","00000003"),apiTestCase("test_111"),apiTestCase("test_111"),apiTestCase("test_00000001",'00000004',1)]
    tests = [apiTestCase("test_show")]
    suite.addTests(tests)
    '''
    runner = unittest.TextTestRunner(verbosity=2)
    runner.run(suite)
    



    suite.addTests(unittest.TestLoader().loadTestsFromTestCase(apiTestCase))
    '''
    with open('HTMLReport.html', 'w') as f:
        runner = HTMLTestRunner.HTMLTestRunner(
            stream=f,
            title='测试报告',
            description='generated by HTMLTestRunner.',
            verbosity=2)
        runner.run(suite)
Beispiel #13
0
import unittest
import HTMLTestRunner

class MyFirstUnit(unittest.TestCase):
    def test_casel(self):
        self.assertEqual("a","a","there are not equal")  #assert 断言
        print("11111111111111")

    def test_case_num(self):
        self.assertEqual("a", "a", "they are not equal.")  # assert 断言
        print("nnnnnn")

    def test_case_list(self):
        self.assertListEqual([1, 2, 3], [1, 2, 3], "there are not equal")
        print("LLLLLLLLLLL")


if __name__ == "__main__":
    testunit = unittest.TestSuite()
    testunit.addTest(MyFirstUnit("test_casel"))
    testunit.addTest(MyFirstUnit("test_case_num"))
    testunit.addTest(MyFirstUnit("test_case_list"))
    filename = 'E:\\Python\\TestFan-20181202\\report\\MyFirstUnitResult.html'
    fp = open(filename, 'wb')
    runner = HTMLTestRunner.HTMLTestRunner(
    stream=fp,
    title='MyFirstUnit测试报告',
    description='用例执行情况:')
    runner.run(testunit)        #run(套件名字)
Beispiel #14
0
import HTMLTestRunner
import unittest
import os
import sys
sys.path.append(os.path.abspath("."))
from testsuites.test_login_post_reoly import test_login_post_reoly
from testsuites.test_del_mes_and_newmodule import test_del_mes_and_newmodule
from testsuites.test_search_mes import test_search_mes
from testsuites.test_release_vote import test_release_vote
#构造存储路径
report_path = os.path.dirname(
    os.path.abspath(".")) + "/songxuedong_web_Discuz/report/"
if not os.path.exists(report_path): os.mkdir(report_path)
#构造测试套件
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(test_login_post_reoly))
suite.addTest(unittest.makeSuite(test_del_mes_and_newmodule))
suite.addTest(unittest.makeSuite(test_search_mes))
suite.addTest(unittest.makeSuite(test_release_vote))
#执行
if __name__ == '__main__':
    html_report = report_path + r'\report.html'
    fp = open(html_report, "wb")
    runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
                                           verbosity=2,
                                           title="Discuz测试",
                                           description="Discuz主要流程测试")
    runner.run(suite)
Beispiel #15
0

# 取test_case文件夹下所有用例文件
def creatsuitel(lists):
    testunit = unittest.TestSuite()
    # discover 方法定义
    discover = unittest.defaultTestLoader.discover(lists,
                                                   pattern='TC_*.py',
                                                   top_level_dir=None)
    #discover 方法筛选出来的用例,循环添加到测试套件中
    for test_suite in discover:
        for test_case in test_suite:
            testunit.addTests(test_case)
            print(testunit)
    return testunit


list_1 = 'TestCasesRepository'
alltestnames = creatsuitel(list_1)

#取前面时间加入到测试报告文件名中
now = time.strftime("%Y-%m-%M-%H_%M_%S", time.localtime(time.time()))
filename = "report\\" + now + 'result.html'  #定义个报告存放路径,支持相对路径。
fp = open(filename, 'wb')
runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
                                       title='Report_title',
                                       description='Report_description')

if __name__ == "__main__":
    # 执行测试用例集并生成报告
    runner = unittest.TextTestRunner()
Beispiel #16
0
    # 发送邮箱用户名/密码
    # username = '******'
    # password = '******'
    smtp.sendmail(sender,receiver, msg.as_string())
    smtp.quit()
    print('email sent')

def sendreport() :
    result_dir = 'D:\TestingReport'
    lists = os.listdir(result_dir)
    lists.sort(key=lambda fn:   os.path.getatime(result_dir+'\\'+fn)
                                         if not os.path.isabs(result_dir + '\\' + fn) else 0)
    print('最新的测试报告为: ' + lists[-2])
    file = os.path.join(result_dir, lists[-2])
    print(file)
    sendmain(file)


now=time.strftime("%Y-%m-%d-%H_%M_%S",time.localtime(time.time()))
file = 'D:/TestingReport/' + now + 'TestReport.html'
fp = open(file,'wb')

runner = HTMLTestRunner.HTMLTestRunner(
    stream=fp,
    title = u'敦崇云AC测试报告: ',
    description = u'用例执行详情: '
)

if __name__ == '__main__' :
    runner.run(testunit)
    sendreport()
Beispiel #17
0
    daily_folder = time.strftime("%Y%m%d", time.gmtime(time.time()))
    report_path = "./reports/" + daily_folder
    if (not os.path.exists(report_path)):
        os.mkdir(report_path)

    fp = open(
        report_path + '/RegressionReport' +
        time.strftime("%H%M%S", time.gmtime(time.time())) + '.html', 'wb')

    # Invoke TestRunner
    #runner = unittest.TextTestRunner(buf)       #DEBUG: this is the unittest baseline
    runner = HTMLTestRunner.HTMLTestRunner(
        stream=fp,
        title='<Regression Test Report>',
        description=
        'This is the result of the regression tests performed on the folowing release branch: ',
        rlist=repo_list,
        verbosity=2)
    runner.run(newsuite)
    fp.close()

    #---------------------------------------------------------------------------#
    # Code coverage
    #---------------------------------------------------------------------------#
    if coverage_available:
        cov.stop()
        cov.save()
        print('\nCoverage Summary:')
        cov.report()
        basedir = os.path.abspath(os.path.dirname(__file__))
Beispiel #18
0
        if self.username is not None and self.password is not None:
            import splunk
            try:
                session_key = splunk.auth.getSessionKey(username=self.username,
                                                        password=self.password)

                # This assumes you are testing against a non-SHC environment
                self.assertEquals(ServerInfo.is_shc_captain(session_key), None)
            except splunk.SplunkdConnectionException:
                pass
        else:
            self.skipTest(
                'Skipping test since Splunk authentication data is not available'
            )


if __name__ == '__main__':
    report_path = os.path.join(
        '..', os.environ.get('TEST_OUTPUT', 'tmp/test_report.html'))

    # Make the test directory
    try:
        os.makedirs(os.path.dirname(report_path))
    except OSError as exception:
        if exception.errno != errno.EEXIST:
            raise

    with open(report_path, 'w') as report_file:
        test_runner = HTMLTestRunner.HTMLTestRunner(stream=report_file)
        unittest.main(testRunner=test_runner)
Beispiel #19
0
import unittest, os, HTMLTestRunner
import sys
sys.path.append("G:\\pythonWorkSpace\\workspace\\UI_autotest\\")

test_dir = './'
suite = unittest.TestLoader().discover(test_dir, pattern='test_test*.py')

cur_path = os.path.dirname(os.path.realpath(__file__))
report_path = os.path.join(cur_path, "reports")
if not os.path.exists(report_path):
    os.mkdir(report_path)

if __name__ == '__main__':
    html_report = report_path + r"\result.html"
    fp = open(html_report, 'wb')
    runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
                                           verbosity=2,
                                           title='单元测试报告',
                                           description='用例执行情况')

    # runner=unittest.TextTestRunner(verbosity=2)
    runner.run(suite)
Beispiel #20
0
 def build_report(self):
     runner = HTMLTestRunner.HTMLTestRunner(
         stream=self.fp,
         title='test_report',
         description='mamainst_test_interface')
     return runner
Beispiel #21
0
    def tearDownClass(cls):
        cls.log.close_handle()
        cls.driver.close()

    #送财务登账-不填发票号-财务登账
    def test_danw_dengz_butfp_caiw_dengz(self):
        self.driver.refresh()
        self.zl.unit_dengz.songcw()
        self.driver.refresh()
        success = self.zl.fin_dengz.dengz_success()
        self.assertTrue(success, "登账成功")

    #送财务登账-填发票号-财务退回
    def test_danw_dengz_tianfp_caiw_tui(self):
        self.driver.refresh()
        self.zl.unit_dengz.songcw(1000)
        self.driver.refresh()
        success = self.zl.fin_dengz.tuih_success()
        self.assertTrue(success, "退回成功")


if __name__ == "__main__":
    file_path = os.path.join(os.getcwd() + "/report/" + "test_case.html")
    f = open(file_path, 'wb')
    suite = unittest.TestSuite()
    suite.addTest(DengzCase('test_danw_dengz_butfp_caiw_dengz'))
    #suite.addTest(DengzCase('test_danw_dengz_tianfp_caiw_tui'))
    runner = HTMLTestRunner.HTMLTestRunner(
        stream=f, title="全量测试报告", verbosity=2)
    runner.run(suite)
	print "step22.Go back"
        driver.back()
        time.sleep(3)
        result = driver.title
        assert result == 'FastPass | Customers - Customer search' ,"The page did not be opened correct"
	time.sleep(3)
	
	print "\n"        
        print "Test Case end with successfully!"    
        
    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)
        


if __name__ == '__main__':
    now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
    testunit=unittest.TestSuite()
    testunit.addTest(FastPass_Agile("test_Case_Customer_NoCustomerMatch"))
    filename="C:\LM_IBM_WORK\LM_WORK\FastPass\FastPass_Agile\\result\\"+now+" FastPass_Test_Case_Customer_NoCustomerMatch.html"
    fp=file(filename,'wb')
    runner = HTMLTestRunner.HTMLTestRunner(stream=fp,title='FastPass_Agile Test Case',description='This is Customer_NoCustomerMatch test case')
    runner.run(testunit)




        

Beispiel #23
0
            'ESA_VerifyLink_Customers_p16')
        time.sleep(3)

        print "\n"
        print "step29.hit back"
        driver.back()
        driver.implicitly_wait(10)
        time.sleep(2)
        result = driver.title
        assert result == 'FastPass | Customers - Customer search', "The page did not be opened correct"

        print "\n"
        print "Test Case end with successfully!"

    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)


if __name__ == '__main__':
    now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
    testunit = unittest.TestSuite()
    testunit.addTest(FastPass_Mobile("test_Case_ESA_VerifyLink_Customers"))
    filename = "C:\LM_IBM_WORK\LM_WORK\FastPass\FastPass_Mobile\\result\\" + now + " FastPass_Test_Case_ESA_VerifyLink_Customers.html"
    fp = file(filename, 'wb')
    runner = HTMLTestRunner.HTMLTestRunner(
        stream=fp,
        title='FastPass_Mobile Test Case',
        description='This is ESA_VerifyLink_Customers test case')
    runner.run(testunit)
Beispiel #24
0
            f.write("old_list: %s\n" % old_list[i])
            f.write("new_list: %s\n" % new_list[i])
            self.assertEqual(old_list[i], new_list[i])
            f.write("------------------------------\n")
        f.write("=============================================================================\n")

    def tearDown(self):
        pass

if __name__ == "__main__":
    test_suite = unittest.TestSuite()
    test_suite.addTests(unittest.makeSuite(ad_calc_category))

    print test_report
    fp = file(test_report.encode('GBK'), 'wb')
    runner = HTMLTestRunner.HTMLTestRunner(
        stream=fp,
        title=u'列表页计算模块---百货, version = %s' % version,
        description=u'所有的category_id请求出的数据,对比新老产品的同一版本的结果是否一致。本测试用例仅适用于所有广告都是按照score排序进行比对的, 仅适用于1,3,4 版本'
    )
    runner.run(test_suite)
    subject = runner.title
    file_list = [test_report]
    fp.close()
    f.close()
    email_contents = "列表页计算模块版本比对百货分类页测试完毕\n本次测试版本为:%s\n测试报告地址:%s\n测试日志地址:%s\n" % (version.encode('utf-8'), test_report.encode('utf-8'), test_log.encode('utf-8'))
    #new_send_mail(subject, files=[], to_list=['[email protected],[email protected],[email protected],[email protected]'], contents= email_contents)
    new_send_mail(subject, files=[], to_list=['*****@*****.**'], contents= email_contents)


Beispiel #25
0
        # 定义附件的类型
        xlsxpart = MIMEApplication(open('C:/Users/user01/Desktop/apidemo.xls', 'rb').read())
        xlsxpart.add_header('Content-Disposition', 'attachment', filename='apidemo.xls')
        msg.attach(xlsxpart)

        try:
            client = smtplib.SMTP_SSL('smtp.qq.com', 465)
            client.login(username, password)
            client.sendmail(sender, receivers, msg.as_string())
            client.quit()
            # print (f'带有附件{name}的邮件发送成功!')

        except:
            print('邮件发送失败')


if __name__=='__main__':
    testsuit = unittest.TestSuite()
    pathcode = 'C:/Users/user01/PycharmProjects/untitled/'
    testsuit.addTest(diyige('test_ReadExcel'))
    testsuit.addTest(diyige('test_mail'))
    cuitime = time.strftime('%Y%m%d%H%M%S',time.localtime())
    HtmlFile =pathcode+cuitime+'.html'
    #HtmlFile = cuitime+'.html'
    #HtmlFile = 'result.html'
    fp =open(HtmlFile,'wb')
    runner = HTMLTestRunner.HTMLTestRunner(stream=fp,title='接口测试报告',description='rippton')
    runner.run(testsuit)
    fp.close()
Beispiel #26
0
        MyTests = Tests(config)

        # create test log file
        t = time.localtime()
        # ts = str(t.tm_year) + '-' + str(t.tm_mon) + '-' + str(t.tm_mday) + \
        # 	'_' + str(t.tm_hour) + '-' + str(t.tm_min) + '-' + str(t.tm_sec)
        # log = config['test_output_path'] + 'test_result-' + ts + '.log'
        # f = open(log, "a")
        ts = str(t.tm_year) + '-' + str(t.tm_mon) + '-' + str(t.tm_mday) + \
            '_' + str(t.tm_hour) + '-' + str(t.tm_min) + '-' + str(t.tm_sec)
        report = config['test_output_path'] + 'report-' + ts + '.html'

        with open(report, "w") as f:
            HTMLTestRunner.HTMLTestRunner(
                stream=f,
                title='Kaifaban19 report',
                verbosity=2,
                description='Sample test for HTMLTestRunner usage').run(
                    MyTests.test_suite())

            # create command-line test runner
            # runner = unittest.TextTestRunner(f)
            # runner.verbosity = 2
            # start test execution
            # unittest.main(defaultTest='MyTests.test_suite', testRunner=runner)

            if DEBUG:
                print '#' * 50
                print 'Test finished. Please check log under ./' + config[
                    'test_output_path']

    except KeyError as ke:
        f.write(
            "=============================================================================\n"
        )

    def tearDown(self):
        pass


if __name__ == "__main__":
    test_suite = unittest.TestSuite()
    test_suite.addTests(unittest.makeSuite(ad_calc_search))
    print test_report
    fp = file(test_report.encode('GBK'), 'wb')
    runner = HTMLTestRunner.HTMLTestRunner(
        stream=fp,
        title=u'搜索页计算模块--图书query新老产品版本结果比对',
        description=
        u'针对所有预测为图书的query,对比新老产品的同一版本的结果是否一致,针对图书的query。本测试用例仅适用于所有广告都是按照bid+str排序进行比对的'
    )
    runner.run(test_suite)
    subject = runner.title
    file_list = [test_report]
    fp.close()
    f.close()
    email_contents = "搜索页计算模块版本比对测试完毕,该测试为图书搜索词测试\n本次测试版本为:%s\n测试报告地址:%s\n测试日志地址:%s\n" % (
        version.encode('utf-8'), test_report.encode('utf-8'),
        test_log.encode('utf-8'))
    new_send_mail(subject,
                  files=[],
                  to_list=['*****@*****.**'],
                  contents=email_contents)
Beispiel #28
0
# coding:utf-8
__author__ = 'Helen'
'''
description:执行测试
'''
import unittest,time,HTMLTestRunner
from config.globalparameter import test_case_path,report_name
from src.common import send_mail
from src.test_cases import test_Interface


# 构建测试集,包含src/test_case目录下的所有以test开头的.py文件
suite = unittest.defaultTestLoader.discover(start_dir=test_case_path,pattern='test*.py')

# 执行测试
if __name__=="__main__":
    report = report_name+"Report.html"
    fb = open(report,'wb')
    runner = HTMLTestRunner.HTMLTestRunner(
        stream=fb,
        title=u'官网自动化测试报告',
        description=u'项目描述:开发环境'
    )
    runner.run(suite)
    fb.close()
    # 发送邮件
    time.sleep(10)  # 设置睡眠时间,等待测试报告生成完毕(这里被坑了==)
    email = send_mail.send_email()
    email.sendReport()
Beispiel #29
0
    ) + '<br/>' + '[预期结果]<br/>' + res_check.decode(
    ) + '<br/>' + '<br/>' + '[响应数据]<br />' + '<br/>' + response.decode()
    print(bugdetail)
    sql = "INSERT INTO `bug_bug` (`bugname`,`bugdetail`,`bugstatus`,`buglevel`, `bugcreater`,`bugassign`, `created_time`, `Product_id`) VALUES('%s', '%s', '1', '1', '邹辉', '邹辉', '%s','2');" % (
        bugname, pymysql.escape_string(bugdetail), now)
    coon = pymysql.connect(user='******',
                           passwd='root',
                           db='autotest',
                           port=3306,
                           host='127.0.0.1',
                           charset='utf8 ')
    cursor = coon.cursor()
    cursor.execute(sql)
    coon.commit()
    cursor.close()
    coon.close()


if __name__ == ' main ':
    now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
    testunit = unittest.TestSuite()
    testunit.addTest(ApiFlow("test_readSQLcase"))
    filename = "C:\\Users\\zh\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\\autotest\\apitest\\templ ates\\" + "apitest_report.html"
    fp = open(filename, 'wb')
    runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
                                           title=u"流程接口测试报告",
                                           description=u"流程场景接口")
    runner.run(testunit)
    #readSQLcase()
    print('Done!')
    time.sleep(1)
Beispiel #30
0
    #用例执行完成后,清理状态,这里即关闭app
    def tearDown(self):
        self.driver.close_app()
        self.driver.quit()

    #测试用例函数,编写测试用例
    def calculator(self):
        self.driver.find_element_by_name("7").click()
        self.driver.find_element_by_name("+").click()
        self.driver.find_element_by_name("5").click()
        self.driver.find_element_by_name("=").click()


#运行测试用例
if __name__ == "__main__":
    #定义测试用例的容器Test
    test = unittest.TestSuite()
    #将测试用例使用addTest装入容器中
    test.addTest(jisuanqi("calculator"))

    #测试用例执行结果报告文件路径
    file_path = "F:\\MerciGo\\Reports\\result.html"
    #测试结果报告html打开方式wb
    file_result = open(file_path, "wb")
    #测试用例执行后测试报告写入
    runner = HTMLTestRunner.HTMLTestRunner(stream=file_result, title="计算器简单测试")
    #测试执行
    runner.run(test)
    #运行完成后close掉报告的html
    file_result.close()