allure-pytest配置
时间: 2023-12-26 12:28:09 浏览: 36
以下是配置allure-pytest的步骤:
1. 安装allure-pytest插件:
```shell
pip install allure-pytest
```
2. 在pytest运行完成后生成allure报告的文件:
在pytest的主程序中添加以下代码:
```python
import pytest
if __name__ == '__main__':
pytest.main(["-s", "-v", "--alluredir=Outputs/allure"])
```
其中,`--alluredir`参数指定了生成allure报告的目录。
3. 执行pytest命令时添加allure命令参数:
在执行pytest命令时,添加`--alluredir`参数,并指定生成allure报告的目录,例如:
```shell
pytest --alluredir=Outputs/allure
```
其中,`Outputs/allure`是相对于pytest命令所在目录的测试报告目录。
这样,当pytest运行完成后,会在指定的目录下生成allure报告文件。
相关问题
allure-pytest-2.13.2
引用提到了allure-pytest-2.13.2,它是一个用于生成allure能解析的测试结果文件的插件。可以通过pip install allure-pytest命令进行安装。安装完成后,可以使用pytest.main(['-vs','--alluredir=reports/allurefile'])命令生成allure能解析的测试结果文件。
另外,引用提到了修改allure配置,可以通过打开安装目录,找到allure-2.13.2,然后进行相应的配置修改。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Mac pytest结合allure-pytest生成allure测试报告](https://blog.csdn.net/qq_37982823/article/details/122896297)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *3* [自动化测试框架Pytest(三)——自定义allure测试报告](https://blog.csdn.net/m0_58026506/article/details/126250550)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
pycharm中运行allure-pytest插件只能用python方式
是的,PyCharm中运行allure-pytest插件需要使用Python方式。可以通过以下步骤来使用:
1. 在PyCharm中打开项目。
2. 打开终端,确保已安装pytest和allure-pytest插件。
3. 在终端中输入以下命令来运行测试并生成报告:
```
pytest --alluredir=<report_path>
```
其中,`<report_path>`是报告生成的路径,可以自定义。
4. 在终端中输入以下命令来生成HTML报告:
```
allure generate <report_path> -o <report_output_path> --clean
```
其中,`<report_path>`是上一步生成的报告路径,`<report_output_path>`是报告输出的路径,可以自定义。
5. 在PyCharm中打开生成的HTML报告,查看测试结果。
注意:在PyCharm中,需要使用Python方式来运行pytest命令,而不是使用终端。可以在PyCharm的配置中设置Python解释器和pytest路径。