wda+allure
时间: 2023-07-04 09:23:59 浏览: 159
WDA是一个用于iOS端自动化测试的Python库,而allure是一个用于生成漂亮报告的工具。要将WDA测试结果集成到allure报告中,可以使用pytest和allure-pytest插件来实现。
首先需要安装pytest和allure-pytest插件,可以使用以下命令进行安装:
```
pip install pytest
pip install allure-pytest
```
安装完成后,在pytest的测试用例中,可以使用pytest的fixture和allure的装饰器来将WDA测试结果保存到allure报告中。下面是一个示例:
```python
import wda
import allure
import pytest
@pytest.fixture(scope='module')
def client():
c = wda.Client()
return c
@allure.feature('WDA测试')
class TestWDA(object):
@allure.story('测试页面标题')
def test_title(self, client):
title = client.title()
assert title == 'Example Page'
allure.attach(client.screenshot(format='png'), name='screenshot', attachment_type=allure.attachment_type.PNG)
@allure.story('测试按钮点击')
def test_button(self, client):
btn = client(name='example_button')
btn.tap()
assert btn.exists
allure.attach(client.screenshot(format='png'), name='screenshot', attachment_type=allure.attachment_type.PNG)
```
在上面的示例中,使用了一个名为`client`的fixture来获取WDA的客户端连接,然后使用`allure.feature`和`allure.story`装饰器来定义测试用例的特性和故事。在每个测试用例中,使用了`allure.attach`方法将截图保存到allure报告中。
最后,可以使用以下命令来运行测试,并生成allure报告:
```
pytest --alluredir ./allure-results
allure serve ./allure-results
```
这样就可以将WDA测试结果集成到allure报告中,并且在报告中查看测试结果和截图。
阅读全文
相关推荐














