(实践记录三)appium自动化po模式之main函数pytest运行cases
程序员文章站
2024-02-27 13:53:39
...
(实践记录三)appium自动化PO模式之main函数pytest运行cases
# -*- coding:utf-8 -*-
import pytest
import os
import allure
import logger
from Cases.mydriver import mydriver
from Pages import searchpage,fcirclepage
#实例化封装的Logger
LOG=logger.Logger("TestDemo").getlog()
class TestDemo:
def setup(self):
LOG.debug("TEST START")
self.driver=mydriver()
#测试搜索联系人功能
@pytest.mark.parametrize("name",["h","ha"])
def test_search_contact(self,name):
LOG.debug("test_search_contact")
search=searchpage.search(self.driver)
search.search_contacts(name)
#测试发表文字功能
def test_publish_word(self):
LOG.debug("test_publish_word")
publish=fcirclepage.fcirclepublish(self.driver)
publish.publish_word()
def teardown(self):
LOG.debug("TEST FINISH")
self.driver.quit()
if __name__ == '__main__':
#存放xml、html的报告路径
path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
file_result = path + "/result/xml"
file_report=path+"/result/html"
#pytest+allure执行脚本,生成测试报告
pytest.main(['-s', '-q', '--alluredir', file_result])
#查看测试报告的方法
#print("cmd下生成HTML报告:"+"allure generate "+ file_result+" -o "+file_report+" --clean")
#print("查看HTML报告:"+"allure open -h 127.0.0.1 -p 8083 "+file_report)
上一篇: java回调机制实例详解