pytest -k 参数的用法—笔记

2020-12-30  本文已影响0人  霍格沃兹测试学院

-k参数的用法,示例代码如下:

def test_a():
    print("test_a")

class TestDemo():

    def test_one(self):
        print("开始执行 test_one 方法")
        x = 'this'
        assert 'h' in x

    def test_two(self):
        print("开始执行 test_two 方法")
        x = 'hello'
        assert 'e' in x

    def test_three(self):
        print("开始执行 test_three 方法")
        a = 'hello'
        b = 'hello world'
        assert a not in b

class TestDemo1():
    def test_one(self):
        print("开始执行 test_one 方法")
        a = 'hello'
        b = 'hello world'
        assert a not in b

    def test_o2(self):
        print("开始执行 test_o2 方法")
        x = 'this'
        assert 'h' in x

    def test_3(self):
        print("开始执行 test_3 方法")
        x = 'hello'
        assert 'e' in x

-k "TestDemo1"

-k "Test"

-k "TestDemo and not test_o"

(文章来源于霍格沃兹测试学院)

更多技术文章可点击http://qrcode.testing-studio.com/f?from=jianshu&url=https://ceshiren.com/t/topic/3822

上一篇 下一篇

猜你喜欢

热点阅读