python 测试用例的无输入_自学python遇到的问题_测试用例运行成功但是无法生成测试报告...

使用Python ,HTMLTestRunner 生成测试报告时,遇到很奇怪的问题,明明运行的结果,没有任何报错,就是不生成测试报告

解决方法

1: filename = ‘E:\testresult.html’,如果是在windows环境,文件名要使用以下几种格式。

①filename = 'E:\\testresult.html’ ②filename = r'E:\testresult.html' ③filename = 'E:/testresult.html'

2:若不是使用with做文件的上下文管理,记得要fp.close() 关闭打开的文件,才可以保存。

fp = open(filename, 'wb') fp.close()

3:第三种就奇葩了,看截图(截图为同一代码)(Pycharm IDE)

图一

3d5e9734f94719ebad9d61abac7e0010f1b.png

图二

eca2c21906aef8d6818c8be1c12c78c0413.png

如果是以图一方式运行,就不会有报告生成,至于原因,可能是因为if name == ‘main‘。的原因

2016年11月25日09:01:08,大概知道什么原因了,因为Pycharm 自带测试框架,在右上角,

923f974f11e0e156dc95843ce93bcce81c9.png

点击Edit Configurations→Python tests→选中你要删除的项目

865ba80d79b7d7bd59f282e563c34edc2b7.png

删除,这样就不会自动执行unittest。

4:又遇到一种情况,按照以上3个方法都不行,使用快捷键:Ctrl+shift+F10 还是无法生成report,最后在pycharm的右上角,发现了一个按钮如图

1388306-20180504182725191-440795304.png

这样就可以运行了,⊙﹏⊙汗,完全搞不懂

5:又遇到无法生成测试报告的问题了,按照之前总结的各种方法还是不行,最后,原来就仅仅修改一行代码就可以 了,在此记录下。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Selenium Grid中,可以使用Python编写测试用例并将其分发到多台计算机上运行。下面是一些基本步骤: 1. 安装Selenium Grid并启动Hub和至少一个Node(在不同的计算机上)。 2. 在测试用例中,使用Selenium WebDriver创建一个Remote WebDriver对象并指定Hub的地址和浏览器的配置。 ```python from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities # Specify the Hub URL and the browser configuration hub_url = "http://<hub-ip>:4444/wd/hub" capabilities = DesiredCapabilities.CHROME.copy() capabilities['platform'] = "WINDOWS" capabilities['version'] = "latest" # Create a Remote WebDriver object driver = webdriver.Remote(command_executor=hub_url, desired_capabilities=capabilities) ``` 3. 运行测试用例并观察它们在不同的节点上运行。 ```python driver.get("http://www.google.com") print(driver.title) ``` 4. 将测试用例分配到不同的节点上,以便并行执行测试。 ```python # Specify the node URL and the browser configuration node_url = "http://<node-ip>:5555/wd/hub" capabilities = DesiredCapabilities.CHROME.copy() capabilities['platform'] = "LINUX" capabilities['version'] = "latest" # Create a Remote WebDriver object for the node node_driver = webdriver.Remote(command_executor=node_url, desired_capabilities=capabilities) # Run the tests on the node node_driver.get("http://www.google.com") print(node_driver.title) ``` 这样,您就可以使用Python编写测试用例并将它们分发到多台计算机上运行,以加快测试速度。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值