pytest分类执行pytest.mark.分类名称
1、@pytest.mark.分类名称
2、执行时 '-m','分类名称'
方法一:
class Testb(object): datas = ['zhangsan1','lisi1'] @pytest.mark.smoke @pytest.mark.parametrize('data', datas) def test0001(self,data,writeb): print("传参:",data) return data datas = ['zhangsan2','lisi2'] @pytest.mark.smoke @pytest.mark.parametrize('data', datas) def test0002(self,data,writeb): print("传参:",data) return data datas = ['zhangsan3','lisi3'] @pytest.mark.web @pytest.mark.parametrize('data', datas) def test0003(self,data,writeb): print("传参:",data) return data if __name__ == '__main__': pytest.main(['-s', r'D:\pythonwork\lianxi\pytestlianxi\teste.py','-m','web'])
方法二:
web = pytest.mark.web
@web
web = pytest.mark.web class Testb(object): datas = ['zhangsan1','lisi1'] @pytest.mark.smoke @pytest.mark.parametrize('data', datas) def test0001(self,data,writeb): print("传参:",data) return data datas = ['zhangsan2','lisi2'] @pytest.mark.smoke @pytest.mark.parametrize('data', datas) def test0002(self,data,writeb): print("传参:",data) return data datas = ['zhangsan3','lisi3'] @web @pytest.mark.parametrize('data', datas) def test0003(self,data,writeb): print("传参:",data) return data if __name__ == '__main__': pytest.main(['-s', r'D:\pythonwork\lianxi\pytestlianxi\teste.py','-m','web'])
上班求生存,下班求发展