从BeautifulReport中拿到失败成功和测试时间和消耗时间的数据
时间: 2024-04-08 12:34:02 浏览: 19
你可以使用BeautifulReport库中的一些方法来获取测试报中的失败、成功、测试时间和消耗时间的数据以下是一个示例代码,展示了如何BeautifulReport来获取这些:
```python
importReport
# 加载测试报告
report = BeautifulReport.BeautifulReport('test_report.html')
# 获取失败的用例列表
failed_cases = report.failure_list
# 获取成功的用例列表
passed_cases = report.success_list
# 获取测试时间
test_time = report.time_consuming
# 获取消耗时间
consume_time = report.total_time
# 打印结果
print("失败的用例:", failed_cases)
print("成功的用例:", passed_cases)
print("测试时间:", test_time)
print("消耗时间:", consume_time)
```
在上面的示例中,我们首先使用`BeautifulReport.BeautifulReport`方法加载测试报告文件(这里假设测试报告文件为`test_report.html`)。然后,我们可以使用`failure_list`属性获取失败的用例列表,使用`success_list`属性获取成功的用例列表。`time_consuming`属性获取测试时间,`total_time`属性获取消耗时间。
请确保在运行代码之前已经安装了BeautifulReport库,并且测试报告文件的路径正确。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)