TestSuite search and execute using Marker
テストケースでは、特定のケースを選択して操作を実行するか、無視できます.
Marker
特定のテストケースのタグを管理します.Pytestは、
JUnitなどで使われているラベルと考えられます
pytest.ini
使用を開始する前に、
testcase
次に、
その後、
取捨実行
または、特定のタグ以外のすべてのタグのみを実行するか、特定のタグのみを実行します.
Class
テストコードを管理するもう1つの方法は、これらの関数をクラスに入れ、メソッドで管理することです.
Marker
特定のテストケースのタグを管理します.Pytestは、
Marker
と呼ぶ.JUnitなどで使われているラベルと考えられます
pytest.ini
使用を開始する前に、
pytest.ini
で使用するタグを宣言する必要があります.markers =
smoke: All critical smoke tests
regression: All regression tests
engine: All car engine tests
body: All car body tests
entertainment: All car entertainment tests
door: All car dor tests
例えば、上記のように.testcase
次に、
marker
をタグ付けするテストケースコードを含むファイルにインポートします.from pytest import marker
次に、@
を使用して、タグ付けするテストケースに宣言します.@mark.engine
def test_engine_functions_as_expected():
assert True
@mark.{markName}
ここでmarkName
はpytest.ini
で宣言されている.その後、
pytest -m {markName}
で実行される場合、対応するタグ付きのテストケースのみが実行されます.取捨実行
または、特定のタグ以外のすべてのタグのみを実行するか、特定のタグのみを実行します.
pytest -m "{markName} and / or {markName}"
二重引用符の組み合わせnot
/and
/or
|を使用して実行できます.Class
テストコードを管理するもう1つの方法は、これらの関数をクラスに入れ、メソッドで管理することです.
@mark.body
class BodyTests:
@mark.door
def test_body_functions_as_expected(self):
assert True
def test_bumper(self):
assert True
def test_windshielf(self):
assert True
この操作が実行された場合、実行時にクラス内のすべてのメソッドが実行されます(body
markが追加された場合).body and door
に設定されている場合は、body
とdoor
の2つのタグのtest_body_function_as_expected()
のみが実行されます.Reference
この問題について(TestSuite search and execute using Marker), 我々は、より多くの情報をここで見つけました https://velog.io/@dahunyoo/TestSuite-search-and-executeテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol