python數(shù)據(jù)分析做網(wǎng)站百度總部投訴電話

-mini
https://github.com/zx490336534/pytest-mini
微信小程序自動化測試pytest插件/工具
基于MiniTest進(jìn)行pytest改造
使用方法
準(zhǔn)備測試小程序
根據(jù)miniprogram-demo項目介紹運行一次項目
成功運行后關(guān)閉
安裝&更新
pip install pytest-mini --upgrade
引入插件
新建conftest.py文件
from pytest_mini import pluginspytest_plugins = plugins("待測試的小程序項目路徑","微信開發(fā)者工具路徑"
)
例如demo/cases/conftest.py
from pytest_mini import pluginspytest_plugins = plugins("/Users/zhongxin/github/miniprogram-demo", # 待測試的小程序項目路徑"/Applications/wechatwebdevtools.app/Contents/MacOS/cli" # 微信開發(fā)者工具路徑
)
編寫頁面對象
在demo/pages/components_page.py編寫元素定位
from pytest_mini import Mini, Locatorclass ComponentsPage(Mini):view_container = Locator('view', inner_text='視圖容器', desc='組件頁-視圖容器')
在conftest.py中添加
import pytest
from pages.components_page import ComponentsPage@pytest.fixture(scope="session")
def components_page(mini):yield ComponentsPage(driver=mini.driver)
編寫測試代碼
demo/cases/test_home.py
import allurefrom pytest_mini import compose@compose(feature="小程序官方組件展示", story="組件", title='容器視圖操作')
def test_view_container(components_page):with allure.step("點擊容器視圖"):components_page.click(components_page.view_container)assert False, "故意失敗,查看報告截圖"
編寫執(zhí)行&報告展示腳本
demo/cases/allure_debug.py
import os
import pytest
from pytest_mini.constant import Constanttest_cases = ["test_home.py"] # 執(zhí)行的腳本main_list = ['-s', '-v',*test_cases,'--durations=0', '--clean-alluredir','--alluredir', f'{Constant().REPORT_PATH}/allure_results'
]
pytest.main(main_list)
if not os.getenv("BUILD_URL"):os.system(f"{Constant.ALLURE_TOOL} serve {Constant().REPORT_PATH}/allure_results") # 本地執(zhí)行
執(zhí)行測試
運行allure_debug.py文件
查看報告
報告截圖
最后感謝每一個認(rèn)真閱讀我文章的人,禮尚往來總是要有的,雖然不是什么很值錢的東西,如果你用得到的話可以直接拿走:
這些資料,對于【軟件測試】的朋友來說應(yīng)該是最全面最完整的備戰(zhàn)倉庫,這個倉庫也陪伴上萬個測試工程師們走過最艱難的路程,希望也能幫助到你!???