原因:没有执行 main函数中的代码,只执行了测试用例。
如:没有执行print(now)
if __name__ == '__main__':
# unittest.main()
now = datetime.datetime.now().strftime('%Y-%m-%d_%H_%M_%S')
print(now)
html_file = r'D:\file\PycharmProjects\pwq\report\report.html'
fp = open(html_file, "wb")
runner = HTMLTestRunner.HTMLTestRunner(stream=fp,
title="xxxx自动化测试报告",
description="用例执行情况")
testunit = unittest.TestSuite()
testunit.addTest(unittest.TestLoader().loadTestsFromTestCase(LoginCase))
runner.run(testunit)
fp.close()
修改配置:
步骤一:
步骤二:
**【注意】**1、在python中,选择“+”号,创建一个python
2、选择“+”后,创建python
3、Script path:选择需要执行的文件路径,点击“ok”