0
0
Selenium Pythontesting~5 mins

Markers for categorization in Selenium Python - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a marker in pytest and why is it useful?
A marker is a label you add to tests to group or categorize them. It helps run specific sets of tests easily, like all slow tests or all login tests.
Click to reveal answer
beginner
How do you apply a marker to a test function in pytest?
Use the @pytest.mark.<marker_name> decorator above the test function. For example, @pytest.mark.slow marks the test as slow.
Click to reveal answer
beginner
How can you run only tests with a specific marker using pytest?
Use the command: pytest -m <marker_name>. For example, pytest -m slow runs only tests marked as slow.
Click to reveal answer
intermediate
Why should you register custom markers in pytest's configuration file?
Registering markers in pytest.ini helps avoid warnings and documents the purpose of each marker for better team understanding.
Click to reveal answer
intermediate
Give an example of using markers to separate UI tests from API tests.
Mark UI tests with @pytest.mark.ui and API tests with @pytest.mark.api. Then run them separately using pytest -m ui or pytest -m api.
Click to reveal answer
What does the pytest marker @pytest.mark.smoke indicate?
AThe test is part of the smoke test suite
BThe test is expected to fail
CThe test is slow
DThe test is skipped
How do you run tests NOT marked with 'slow' in pytest?
Apytest -m 'not slow'
Bpytest --skip slow
Cpytest -m slow
Dpytest --exclude slow
Where do you register custom markers to avoid warnings?
AIn the Selenium WebDriver config
BIn the test file
CIn the Python interpreter
DIn pytest.ini or tox.ini
Which decorator syntax correctly marks a test as 'api'?
A@pytest.api
B@api.mark
C@pytest.mark.api
D@mark.api
What is a benefit of using markers in test automation?
AThey speed up test execution by skipping all tests
BThey help organize and selectively run tests
CThey automatically fix test failures
DThey replace the need for assertions
Explain how markers help in organizing and running tests in pytest.
Think about labeling tests to run only certain groups.
You got /4 concepts.
    Describe the steps to create and use a custom marker in pytest.
    Consider both code and configuration.
    You got /3 concepts.