Pytest运行测试用例

import pytest

@pytest.mark.P0

def test_case1():

pass # perform some P0 test for your app

def test_case2():

pass

def test_case3():

pass

class TestClass:

def test_case4(self):

pass


[b]1.选择运行特定的某个类[/b]
你可以按照某个测试用例的的模块,类或函数来选择你要运行的case
>pytest -v test_pytest_markers.py::TestClass

[b]2.选择运行特定的某个测试用例, 适合一开始在调试单个测试用例的时候。[/b]
pytest -v test_pytest_markers.py::TestClass::test_method

[b]3.多种组合运行[/b]
>pytest -v test_pytest_markers.py::TestClass test_pytest_markers.py::test_send_http

[b]4.用-k进行关键字匹配来运行测试用例名字子串[/b]
>pytest -v -k case1 test_pytest_markers.py

Pytest Marker 机制

[b]5.用Marker运行[/b]
对于Pytest的测试用例,可以在每一个测试用例加一个marker,比如pytest运行的时就只运行带有该marker的测试用例,比如下面的@pytest.mark.P0。
pytest -v -m "P0" test_pytest_markers.py
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值