当前位置:网站首页>Pytest test framework notes

Pytest test framework notes

2022-06-25 15:41:00 Test Xiaohang

1. Use case identification mechanism

  •  Automatically find in the running project directory  test_ The beginning or _test Final document 
    
  •  The use case file is marked with test_ The first function will be treated as a test case 
  •  The use case file is marked with Test Initial class , Inside test_ Opening method , Will be used as a use case 

2. Use case execution sequence

  •  Use case file names begin with ascii Code to sort 
  •  Use cases in the use case file : Execute in the order of use case writing 

3.pytest Before and after

@pytest.fixture
  •  Parameters :scope: Specify the level before and after ( Use cases function, Test class class, modular module)
  •  Parameters :autouse=True  Automatically add pre and post to use cases 

4.pytest Case marking

  •  stay pytest.ini Register the mark in the file 
  •  Tag use cases :@pytest.mark. Tagnames 
  •  Execute through parameters -m To filter the marked use cases 

5.pytest Use case parameterization

  • @pytest.mark.parametrize('item', cases)
原网站

版权声明
本文为[Test Xiaohang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206251521462526.html