0
0
PyTesttesting~5 mins

Test naming conventions in PyTest - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
Why is it important to follow test naming conventions in pytest?
Following test naming conventions helps pytest automatically discover tests, makes tests easier to understand, and improves collaboration among team members.
Click to reveal answer
beginner
What prefix should pytest test functions start with?
Test functions should start with the prefix test_ so pytest can recognize and run them automatically.
Click to reveal answer
beginner
How should test names be written for clarity?
Test names should be descriptive and clear, explaining what the test checks, often using underscores to separate words, e.g., test_user_login_success.
Click to reveal answer
intermediate
Can pytest test classes have any name?
No, test classes should start with Test (capital T) and should not have an __init__ method to be discovered by pytest.
Click to reveal answer
beginner
What happens if a test function does not start with test_ in pytest?
Pytest will not recognize or run the function as a test, so it will be ignored during test execution.
Click to reveal answer
Which prefix should pytest test functions start with?
Averify_
Bcheck_
Ctest_
Drun_
What is the recommended prefix for pytest test classes?
ATest
Btest
Ctestcase
DclassTest
Why should test names be descriptive?
ATo make tests run faster
BTo avoid errors
CTo reduce code size
DTo help understand what the test checks
What happens if a test function is named check_login instead of test_login?
APytest ignores it
BPytest runs it normally
CPytest runs it twice
DPytest throws an error
Which of these is a good test function name?
AtestUserLogin
Btest_user_login_success
CuserLoginTest
DloginTest
Explain why pytest test functions must start with test_ and how this affects test discovery.
Think about how pytest finds tests to run.
You got /4 concepts.
    Describe best practices for naming test functions and classes in pytest to improve readability and maintainability.
    Consider clarity and pytest discovery rules.
    You got /5 concepts.