Lav*_*nya 5 python pytest allure
我正在使用py测试诱惑适配器并尝试生成诱惑报告所需的输入数据.但我无法生成任何XML.当我使用py.test sample.py执行py文件时,它确实创建了pycache目录.然后我执行了"诱惑生成-v 1.3.9 C:\ allurereports"(这是我有sample.py的目录).它确实创建了一个诱人的HTML报告,但没有测试用例是0.没有详细信息.
sample.py(与示例中给出的相同)
import allure
@allure.feature('Feature1')
@allure.story('Story1')
def test_minor():
assert False
@allure.feature('Feature2')
@allure.story('Story2', 'Story3')
@allure.story('Story4')
class TestBar:
# will have 'Feature2 and Story2 and Story3 and Story4'
def test_bar(self):
pass
Run Code Online (Sandbox Code Playgroud)
这是使用的py.test命令:py.test sample.py --allure_features = feature1,feature2
任何人都可以帮助我如何从文件中生成一个诱惑报告.有哪些命令要执行.
小智 15
Lavanya.我将尝试解释您必须执行的序列,以生成自动测试的诱惑报告.
安装点子.下载get-pip.py并执行python get-pip.py.
通过pip 安装pytest和pytest-allure-adapter.执行python -m pip install pytest pytest-allure-adapter
生成自动测试诱惑xml报告.执行python -m pytest sample.py --alluredir <some directory>
在<some directory>中出现xml自动测试报告,其中包含sample.py测试的结果.让我们通过allure-cli工具制作美容html报告.
安装allure-cli.下载allure-cli的最新版本.allure-cli需要java.allure-cli不需要安装,只需打开包装即可使用.
生成HTML报告.在unpacked zip中找到诱惑(针对Windows的allure.bat).执行allure.bat generate -o <some directory> -v 1.4.0 <some directory>
在<some directory>中找到index.html并通过浏览器打开它.
*注意 <some directory>对于所有步骤都是相同的
小智 5
有一种非常简单的方法可以通过 allure 生成报告:
首先,安装诱惑:
allure-pytest 2.6.0
allure-python-commons 2.6.0
然后,如果您无法生成报告,请按照以下步骤操作:
(使用pytest)
pytest test_xyz.py --alluredir=path_where_you_want_to_save_reports
Run Code Online (Sandbox Code Playgroud)allure serve report_path
Run Code Online (Sandbox Code Playgroud)如果仍然显示 allure 无法识别命令(blah -blah),则使用 npm 插件使用以下命令安装 allure:
npm install -g allure-commandline --save-dev
Run Code Online (Sandbox Code Playgroud)
然后再次执行步骤(2),然后一台服务器将启动,您将能够看到 allure 报告。
您应该指定测试数据的目录(包含-testsuite.xml文件的目录),而不是测试目录。
您可以使用py.test --alluredir [path_to_report_dir]
它来指定它。
附言。确保您使用正确版本的 allure(最新的 pytest 适配器仅支持 allure 1.4.*)。
有关更多信息,请参阅https://github.com/allure-framework/allure-python和https://github.com/allure-framework/allure-cli
归档时间: |
|
查看次数: |
16714 次 |
最近记录: |