0
0
JUnittesting~5 mins

Test method naming conventions in JUnit - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
Why should test method names be descriptive?
Descriptive test method names help understand what the test checks without reading the code. They make tests easier to maintain and debug.
Click to reveal answer
beginner
What is a common format for naming test methods in JUnit?
A common format is methodName_StateUnderTest_ExpectedBehavior. For example, calculateSum_NegativeNumbers_ReturnsZero.
Click to reveal answer
beginner
True or False: Test method names should avoid spaces and special characters.
True. Test method names should use camelCase or underscores instead of spaces or special characters to keep names valid and readable.
Click to reveal answer
intermediate
What is the benefit of including the expected result in a test method name?
Including the expected result clarifies what the test is verifying, making it easier to understand test failures and the purpose of the test.
Click to reveal answer
beginner
Give an example of a poorly named test method and explain why it is not good.
Example: test1(). This name is not descriptive, so it does not tell what is tested or expected, making it hard to maintain or debug.
Click to reveal answer
Which of the following is a good test method name in JUnit?
Atest
B123testMethod
CcalculateSum_NegativeNumbers_ReturnsZero
Dsum!
Why should test method names avoid spaces?
ASpaces improve readability
BSpaces make tests run slower
CSpaces cause tests to pass automatically
DSpaces are not allowed in method names in Java
What does the part 'ExpectedBehavior' in a test method name describe?
AThe expected outcome of the test
BThe test framework used
CThe input data used
DThe developer who wrote the test
Which naming style is recommended for test methods?
AAll uppercase letters
BcamelCase or underscores
CSpaces between words
DSpecial characters like @ or #
What is the main purpose of good test method naming?
ATo make tests easier to understand and maintain
BTo hide test details from others
CTo reduce the number of tests needed
DTo make tests run faster
Explain why descriptive test method names are important in JUnit testing.
Think about how you find problems quickly when reading test results.
You got /4 concepts.
    Describe a good naming pattern for test methods and why it works well.
    Imagine naming tests like telling a mini story about what they check.
    You got /4 concepts.