十二、捕获异常/截图/测试报告allure

一、捕获异常
记录异常两种形式:
    --使用try....except
    --使用装饰器@logger_handler
二、截图
def screen_shot(self):
"""截图"""
    # log/img/2020-08-01-12-10-20.png
    path = self.handler.conf.IMG_PATH
    ts = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
    filename = os.path.join(path,ts + ".png")
    self.driver.save_screenshot(filename)

三、测试报告allure

--安装allure包
--安装pip install allure-pytest
--运行allure serve 文件路径。
pytest,main(["--alluredir=allureout".format(ts)])
运行allure测试报告:
D:Program Files (x86)PyCharmworkspacefutureloan_web>allure serve allureout

Jenkins配置

 

 

原文地址:https://www.cnblogs.com/zhangjx2457/p/13841496.html