# -*- coding: utf-8 -*- # @Time : 2020/12/20 14:59 # @Author : fcj11 # @Email : [email protected] # @File : run_test.py # @Project : meishiyuan import unittest import time from BeautifulReport import BeautifulReport from config.config import REPORT_PATH, CASE_PATH suite = unittest.defaultTestLoader.discover(CASE_PATH, 'test_case.py') now_time = time.strftime("%Y%m%d%H%M%S") filename = f'meishiyuan-report-{now_time}' runner = BeautifulReport(suite) runner.report(description='美食源购物流程自动化测试', filename=filename, report_dir=REPORT_PATH)
from my_test.test_unittest_login import TestLogin import time import unittest from BeautifulReport import BeautifulReport from app_config import BASE_DIR suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestLogin)) # report_name = "report" + ".html" report_name = time.strftime("%Y%m%d %H%M%S") + ".html" report_dir = BASE_DIR + "/report" BeautifulReport(suite).report(description="必填注释", filename=report_name, report_dir=report_dir)
import unittest,time from BeautifulReport import BeautifulReport from config.relative_location import path from testCaseSet_Aerocheck import test_UseCaseSet_Aerocheck """执行测试用例,生成测试报告""" # 测试报告名称 file_name=time.strftime("%m%d%H%M%S")+"Aerobook测试报告" # 测试报告名称 # 测试报告存放地址 relativeAddress = path.location() print("relativeAddress:",relativeAddress) logPath = relativeAddress+"report//Aerocheck//" # 测试报告保存地址 # 用例名称 useCase_name="Aerocheck测试报告" """用于测试报告中的截图""" if __name__ == '__main__': suite = unittest.TestSuite() suite.addTests(unittest.TestLoader().loadTestsFromTestCase(test_UseCaseSet_Aerocheck)) result = BeautifulReport(suite).report(filename=file_name,log_path=logPath,description=useCase_name)
============================ Author:周振全 Time:2020/2/14 8:09 下午 E-mail:[email protected] ============================ """ import os import unittest from Library.HTMLTestRunnerNew import HTMLTestRunner from Common.Path import CASEDIR, REPORTDIR from Common.filetime import File_time from BeautifulReport import BeautifulReport from Test_Case import test_Main from Common.Email import send_email suite = unittest.TestSuite() loader = unittest.TestLoader() suite.addTest(loader.discover(CASEDIR)) # suite = unittest.defaultTestLoader.loadTestsFromModule(test_Main) # file_path = os.path.join(REPORTDIR, File_time.time() + 'report.html') # runner = HTMLTestRunner(stream=open(file_path, 'wb'), # title="Python报告", # description="登录测试", # tester="周振全") # runner.run(suite) # send_email(file_path,"Python_24报告") br = BeautifulReport(suite) br.report("前程贷用例",filename=File_time.time() + 'report.html',report_dir=REPORTDIR)
# @Project : mryx import unittest import time from conf.config import case_path, report_path from BeautifulReport import BeautifulReport from testcase.test_add_gwc import AddgwcTest from testcase.test_paixu import PaixuTest from testcase.test_sousuo import SousuoTest from testcase.test_ts_login import TishiTest """执行所有用例""" # 创建测试集 suite = unittest.TestSuite() testa1 = AddgwcTest("test_add_goods") testa2 = AddgwcTest("test_add_gwc") testb1 = PaixuTest("test_price") testb2 = PaixuTest("test_sales") testc1 = SousuoTest("test_clear_sousuo") testc2 = SousuoTest("test_sousuo") testd1 = TishiTest("test_ts_login") testd2 = TishiTest("test_share_goods") suite.addTests((testa1, testa2, testb1, testb2, testc1, testc2, testd1, testd2)) # 创建执行器 runner = BeautifulReport(suite) # 执行 filename = "{}{}.html".format("ECShop-report-",time.strftime("%Y%m%d%H%M")) runner.report(description="每日优鲜APP测试报告", filename=filename, report_dir=report_path)
import unittest from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from BeautifulReport import BeautifulReport class TestCase_5itest(unittest.TestCase): def setUp(self): print('开始5itest测试套件运行') self.driver = webdriver.Chrome(executable_path='chromedriver') self.driver.maximize_window() self.driver.implicitly_wait(10) self.driver.get('http://www.5itest.cn/register') def test_login(self): self.driver.find_element_by_id('register_email').send_keys('') self.driver.find_element_by_id('register-btn').click() self.assertTrue(EC.title_contains('注册')) def tearDown(self): print('结束5itest测试套件运行') self.driver.quit() if __name__ == '__main__': # test_suite = unittest.TestSuite() # test_suite .addTest(TestCase_5itest('test_login')) # unittest.TextTestRunner().run(test_suite) test_suite = unittest.defaultTestLoader.discover('.', pattern='test_*.py') result = BeautifulReport(test_suite) result.report(filename='测试报告', description='第一次生成测试报告', log_path='report')
# 1.导包 import time import unittest from BeautifulReport import BeautifulReport from utils import app # 2.组织要运行得测试套件 suite = unittest.TestLoader().discover(start_dir=app.GET_PATH + "/script/", pattern="test*.py") # 3.定义测试报告的文件名 file_name = "test-{}.html".format(time.strftime("%Y%m%d%H%M%S")) # 4.实例化BeautifulReport的实例运行测试生成报告 # filename:测试报告的文件名 # description:测试报告描述可以理解标题 # log_path:测试报告生成路径 BeautifulReport(suite).report(filename=file_name, description="测试报告", log_path="./report") print("-"*100) print("增加一行,检查!")
# # #编写HTML类型邮件正文 # msg=MIMEText('<html><h1>hello</h1></html>','html','utf-8') # msg['Subject']=Header(subject,'utf-8') #连接发送邮件 # smtp=smtplib.SMTP() # smtp.connect(smtpserver) # smtp.login(user,password) # smtp.sendmail(sender,receiver,msg.as_string()) # smtp.quit() if __name__ == '__main__': test_report='D:\\IC\\other\\Python_code\\manage_unittest\\report\\' now = time.strftime("%Y-%m-%d %H_%M_%S") htmlfile = 'D:\\IC\\other\\Python_code\\manage_unittest\\report\\' suite = unittest.TestSuite() # for i in Monitor.list1: # suite.addTest(ParametrizedTestCase.parametrize(Monitor, 'test_OnlineReport',param=i)) for i in Monitor.list1: suite.addTest(ParametrizedTestCase.parametrize(Monitor, 'test_QueReport',param=i)) BeautifulReport(suite).report(filename='测试报告'+now,description='坐席和队列指标测试_企业:4216082301' ,log_path=htmlfile) new_report=new_report(test_report) send_mail(new_report) # name = 'lily and lucy' # print(name.lower())
name = "xiaogang" pwd = "123456" @classmethod def tearDownClass(cls): sql = "delete from userinfo where username=%s" print(cls.name) mysql.exec_sql(sql, cls.name) def test_index(self): '''test_index...''' self.regist(self.name, self.pwd, self.pwd) token = self.login(self.name, self.pwd) url = "/my/index" method = "post" data = {"name": self.name, "token": token} headers = {"Content-Type": "application/json"} req_obj = MyRequest(url, method, data, headers) expected_res = {"code": "000000"} self.assertTrue(json_assert(expected_res, req_obj.res), "校验失败!预期结果%s 实际结果%s" % (expected_res, req_obj.res)) if __name__ == '__main__': # unittest.main() suite = unittest.makeSuite(TestIndex) bf = BeautifulReport(suite) file_name = "test_report" bf.report(description="Login testing", filename=file_name, log_path=REPORT_PATH) # print(get_params(USER_INFO))
import unittest import time from BeautifulReport import BeautifulReport from day07.exm02_iHRM.case.TestEmp import TestEmp from day07.exm02_iHRM.case.TestiHRMLogin import TestIhrm suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(TestIhrm)) suite.addTest(TestIhrm("test_login_correct")) suite.addTest(TestEmp("test_add_01_mep")) suite.addTest(TestEmp("test_update_02_mep")) suite.addTest(TestEmp("test_get_03_mep")) suite.addTest(TestEmp("test_delete_04_mep")) repot = "黑马iHRM{}.html".format(time.strftime("%Y%m%d%H%M%S")) BeautifulReport(suite).report(filename=repot, log_path="./report", description="人力资源登录测试") print("11")
import unittest from BeautifulReport import BeautifulReport # 导入BeautifulReport suite_tests = unittest.defaultTestLoader.discover( ".", pattern="unittest*.py", top_level_dir=None) # "."表示当前目录,"*tests.py"匹配当前目录下所有tests.py结尾的用例 BeautifulReport(suite_tests).report(filename='设备号', description='测试结果', log_path='.') # log_path='.'把report放到当前目录下
# -*- coding: utf-8 -*- # @Time : 2020/10/19 11:27 # @Author : 墨 # @Email : [email protected] # @File : dyb_run.py # @Project : mryx """这是但钰彪的运行 测试用例有 logout_login_test.py 登录注销 test_activity_news.py 活动消息 test_add_shopping_address.py 添加收货地址测试 test_customer_service.py 客服与服务的测试 test_points_mall.py 积分商城测试 mys_income_withdrawal_page.py 收益不足一元提现 ^ test_good_ticket.py 优惠券测试 ^ test_help_get_free.py 助力免费测试 """ from conf.config import TESTCASE_PATH, REPORT_PATH import unittest import time from BeautifulReport import BeautifulReport from testcase.logout_login_test import LogoutLogingTest suite = unittest.TestSuite() suite.addTest(LogoutLogingTest("test_MRYX_ST_usr_002")) runner = BeautifulReport(suite) strTime = time.strftime("%Y%m%d%H%M") file_name = "mysx_dyb_" + strTime + ".html" runner.report(description="每日优鲜测试用例", log_path=REPORT_PATH, filename=file_name)
# elif args_list[1] in 'events': # print('test events...') # run_proj = "events" # elif args_list[1] in 'users': # print('test users...') # run_proj = "users" # elif args_list[1] in 'shop': # print('test shop...') # run_proj = "shop" # else: # print('args error!') # sys.exit(1) # 自动发现方式运行用例 with open(reportName, 'wb') as fp: beaRep = BeautifulReport(discover) # 默认在当前路径下,可以加log_path res = beaRep.report(filename=reportName, description='接口自动化测试') logger.info(' 测试结果统计 '.center(100, '%')) for key, value in res.items(): if key == 'testResult': # 测试结果详细不在此输出 continue logger.info('{key}:{value}'.format(key=key, value=value)) logger.info(' 测试结果统计 '.center(100, '%')) ''' 返回结果格式 FIELDS = { "testPass": 0, "testResult": [ ], "testName": "",
self.p1.login_admin(self.login_name2) sleep(2) self.p1.login_powd(self.login_pwd2) self.p1.loginname_null("请输入正确的手机号码!") def test_4(self): '''密码为空''' print(3) self.p1.login_admin(self.login_name3) sleep(2) self.p1.logig_clic() sleep(3) self.p1.loginpwd_null("请输入密码") def tearDown(self): self.p1.quit() print("运行结束") if __name__ == "__main__": suite = unittest.TestSuite() suite.addTest(test_login("test_1")) suite.addTest(test_login("test_2")) suite.addTest(test_login("test_3")) suite.addTest(test_login("test_4")) now = time.strftime("%Y-%m-%d %H_%M_%S") filename = now + '测试报告.html' BeautifulReport(suite).report(description="登陆成功测试", filename=filename, log_path="D:\BeautifulReport")
""" ====================== Author: 柠檬班-小简 Time: 2020/7/1 20:36 Project: py30-接口自动化 Company: 湖南零檬信息技术有限公司 ====================== """ import unittest import os from BeautifulReport import BeautifulReport from Common.handle_path import cases_dir, reports_dir # 收集用例 s = unittest.TestLoader().discover(cases_dir) # 生成报告 br = BeautifulReport(s) br.report("py30-注册用例自动化", "report_.html", reports_dir)
""" 组织测试套件实现 登录 与员工增删改查 """ # 导包 import unittest # 组织测试套件 from BeautifulReport import BeautifulReport import app from case.TestIHRMUser import TestUser from case.testIHRMEmploye import TestEmployee suite = unittest.TestSuite() suite.addTest(TestUser("test_login_success")) #登录成功 suite.addTest(TestEmployee("test_emp_add")) suite.addTest(TestEmployee("test_emp_update")) suite.addTest(TestEmployee("test_emp_get")) suite.addTest(TestEmployee("test_emp_delete")) # 执行测试套件 # runner = unittest.THMLTestRunner() # runner.run(suite) BeautifulReport(suite).report(filename="report.html", description="IHRM", log_path=app.PRO_PATH + "/report")
# -*- coding: UTF-8 -*- import unittest from BeautifulReport import BeautifulReport if __name__ == '__main__': # 查找unittest测试类 test_suite = unittest.defaultTestLoader.discover('.', pattern='PO.py') # 调用BeautifulReport执行测试类:还是在使用unittest执行 result = BeautifulReport(test_suite) result.report(filename='test.html', description='测试deafult报告', log_path='.')
import os import HTMLTestRunner from BeautifulReport import BeautifulReport from Common.dir_config import * import unittest from TestCase.test_login import TestLogin suite = unittest.TestSuite() loader = unittest.TestLoader() suite.addTest(loader.loadTestsFromTestCase(TestLogin)) # with open(htmlreport_dir+"/autoTest_report.html","wb") as fp: result = BeautifulReport(suite) result.report(filename='测试报告', description='测试deafult报告', log_path=htmlreport_dir) # runner.run(suite)
def test_fail_case(self): '''这是失败的用例''' print('这是一条失败的用例') res = 3 #self.assertEquals(5,res) self.assertEqual(3,res,"a") ''' if __name__=='__main__': print("aaaa") suite = unittest.TestSuite() #定义一个测试套件 suite.addTests(unittest.makeSuite(TestCalc)) #这个类里面所有的测试用例 # suite.addTest(TestCalc('test_pass_case')) #单个添加用例 result = BeautifulReport(suite) result.report(filename='mpp的测试报告B',description='描述B',log_path='') # 默认在当前路径下,可以加log_path ''' if __name__ == "__main__": print("a") print("b") testunit = unittest.TestSuite() testunit.addTest(yuanding_case("test_login")) # testunit.addTest(yuanding_case("test_scartchWorks")) # testunit.addTest(yuanding_case("scartchWorks_del")) # testunit.addTest(yuanding_case("test_collect")) # testunit.addTest(yuanding_case("test_like")) #testunit.addTest(yuanding_case("close")) BeautifulReport(testunit).report(filename='园丁测试报告', description='园丁测试报告', log_path=r'C:\Users')
import logging from time import sleep import unittest from selenium import webdriver from test_user_login import Test_User_Login from BeautifulReport import BeautifulReport import time logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s') logger = logging.getLogger() class Main(): def main(self): try: self.driver = webdriver.Chrome() login = Test_User_Login() login.test_user_login1() # sleep(3) login_pass_url = self.driver.current_url assert ('mail163_letter#module=welcome.WelcomeModule%7C%7B%7D' in login_pass_url) logger.info('login successfully') finally: self.driver.quit() if __name__ == '__main__': suite_cases=unittest.defaultTestLoader.discover(".",pattern="test*.py") BeautifulReport(suite_cases).report(filename=time.strftime("%Y-%m-%d %H_%M_%S")+"登录126邮箱报告",description="登录126邮箱",log_path=".")
# -*- coding: utf-8 -*- # @Time : 2021/3/8 5:11 下午 # @Author : Lewin # @FileName: main.py # @Software: PyCharm import unittest from BeautifulReport import BeautifulReport if __name__ == '__main__': ts = unittest.TestLoader().discover('.') br = BeautifulReport(ts) br.report('lewin.html')
sys.path.append('C:\\Python37\\DLLs') sys.path.append('C:\\Python37') sys.path.append('C:\\Users\\Administrator\\AppData\\Roaming\\Python\\Python37\\site-packages') sys.path.append('C:\\Python37\\lib\\site-packages') import unittest,time from BeautifulReport import BeautifulReport test_dir='./' discover=unittest.defaultTestLoader.discover(test_dir,pattern='test_*.py') if __name__ == '__main__': # 设置报告文件保存路径,theme="theme_cyan" report_dir ='D:\\Report' # 获取系统当前时间 now = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time())) #now = time.strftime("%Y-%m-%d", time.localtime(time.time())) # 设置报告名称格式 HtmlFile = "CRM自动化测试报告" + now + ".html" result = BeautifulReport(discover) result.report(filename=HtmlFile, report_dir='C:\\Users\\Administrator\\.jenkins\\workspace\\crm_appium', description='CRM自动化测试用例集',theme="theme_cyan") ''' suite_tests = unittest.defaultTestLoader.discover(".", pattern="test*.py",top_level_dir=None) BeautifulReport(suite_tests).report(filename=HtmlFile, description='CRM自动化测试用例集', log_path="C:\\Users\\Administrator\\.jenkins\\workspace\\crm_appium") '''
def run(test_suit): result = BeautifulReport(test_suit) result.report(filename='report.html', description='测试deafult报告', log_path='report')
print("正在载入orig_mix.txt") mini = algorithm.CosineSimilarity('F:/sim_0.8/orig.txt', 'F:/sim_0.8/orig_0.8_mix.txt') print('相似度: %.2f%%' % (mini.main() * 100)) def test_rep(self): print("正在载入orig_rep.txt") mini = algorithm.CosineSimilarity('F:/sim_0.8/orig.txt', 'F:/sim_0.8/orig_0.8_rep.txt') print('相似度: %.2f%%' % (mini.main() * 100)) if __name__ == '__main__': #unittest.main() suite = unittest.TestSuite() suite.addTest(Testcase('test_add')) suite.addTest(Testcase('test_del')) suite.addTest(Testcase('test_dis_1')) suite.addTest(Testcase('test_dis_3')) suite.addTest(Testcase('test_dis_7')) suite.addTest(Testcase('test_dis_10')) suite.addTest(Testcase('test_dis_15')) suite.addTest(Testcase('test_mix')) suite.addTest(Testcase('test_rep')) runner = BeautifulReport(suite) runner.report( description='论文查重测试报告', # => 报告描述 filename='nlp_TFIDF.html', # => 生成的报告文件名 log_path='.' # => 报告路径 )
import os import time import unittest from BeautifulReport import BeautifulReport BASE_DIR = os.path.dirname(os.path.abspath(__file__)) suite = unittest.TestLoader().discover(BASE_DIR + '/script', 'test*.py') # file = 'ihrm{}.html'.format(time.strftime('%Y%m%d%H%M%S')) file = "ihrm{}.html" BeautifulReport(suite).report(filename=file, description='部门管理模块', log_path=BASE_DIR + '/report')
opts, args = getopt.getopt(argv, "he:", ["env="]) except getopt.GetoptError: print('runnerTouring.py -e <environment: dev, staging, live>') sys.exit(2) for opt, arg in opts: if opt in ("-h", "--help"): print('runnerTouring.py -e <environment: dev, staging, live>') sys.exit() elif opt in ("-e", "--env"): env = arg return env if __name__ == "__main__": #set env from script parameter os.environ["env"] = get_argv(sys.argv[1:]) file_name = "{}-result.html".format(time.strftime("%Y%m%d-%H%M%S")) """ with open(file_name, 'wb') as f: runner = HTMLTestRunner(stream=f, title="Auto Testing Report", description="Windows 10 Firefox") discovr = unittest.defaultTestLoader.discover("./proj05_touring/test_case", pattern="T*.py") runner.run(discovr) """ #custom define BeautifulReport.img_path BeautifulReport.img_path = "report/screenshot" #Generate Html Report discovr = unittest.defaultTestLoader.discover( ".", pattern="m0600_check_landing_page.py") BeautifulReport(discovr).report(filename=file_name, description="Auto Testing Report", log_path="report")
pattern='test*.py') #二: 使用addTests 精准添加 from testcases.testwangwu import WanguuTestCase from testcases.testzhangsan import ZhangsanTestCase from testcases.testlisi import LisiTestCase suites = unittest.TestSuite() suites.addTests(unittest.makeSuite(ZhangsanTestCase)) suites.addTests(unittest.makeSuite(LisiTestCase)) suites.addTests(unittest.makeSuite(WanguuTestCase)) # 执行测试的方式 #一直接运行测试 runner = unittest.TextTestRunner() runner.run(suites) #二使用HTMLTestRunner来运行测试,生成测试报告 file = "report/report.html" fp = open(file, 'wb') runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title='Python Test Report', description='This is Python Report') runner.run(suites) fp.close() #三 python3可以使用BeautifulReport来生成测试报告 result = BeautifulReport(suites) result.report(filename='测试报告', description='测试deafult报告', log_path='report')
# 封装执行测试用例 import os import unittest import datetime from BeautifulReport import BeautifulReport from Library.HTMLTestRunnerNew import HTMLTestRunner from common.handle_01path import CASEDIR, REPORTDIR from common.handle_08email import send_email date = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M") suite = unittest.TestSuite() loader = unittest.TestLoader() suite.addTest(loader.discover(CASEDIR)) rf = os.path.join(REPORTDIR, date + "report.html") # runner = HTMLTestRunner(stream=open(rf, "wb"), # title="纳税人学堂项目", # description="纳税人学堂管理端自动化测试", # tester="lily") # runner.run(suite) br = BeautifulReport(suite) br.report("河北学堂项目自动化测试", filename=date + "raport.html", report_dir=REPORTDIR) # send_email(rf, "邮件报告")
import unittest from BeautifulReport import BeautifulReport if __name__ == '__main__': test_suite = unittest.defaultTestLoader.discover('./', pattern='Pramatest.py') result = BeautifulReport(test_suite) result.report(filename='电商项目测试报告', description='电商项目测试报告')
import os import time import unittest import requests from ddt import ddt, file_data from BeautifulReport import BeautifulReport @ddt class RunCase(unittest.TestCase): @file_data('./test_data.json') def test_file_data_json(self, method, url, data): if method == "post": res = requests.post(url, data) print(res.text) if __name__ == '__main__': now = time.strftime('%Y-%m-%d_%H_%M_%S', time.localtime()) filename = now + '.html' report_path = os.path.abspath(os.path.dirname(__file__)) + '/report/' testsuite = unittest.makeSuite(RunCase) runner = BeautifulReport(testsuite) runner.report(description='接口测试报告', filename=filename, log_path=report_path)