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?
✗ Incorrect
Option C is descriptive and follows naming conventions. Others are either too vague or contain invalid characters.
Why should test method names avoid spaces?
✗ Incorrect
Java method names cannot contain spaces, so test method names must avoid them.
What does the part 'ExpectedBehavior' in a test method name describe?
✗ Incorrect
ExpectedBehavior describes what result the test expects to verify.
Which naming style is recommended for test methods?
✗ Incorrect
camelCase or underscores keep names valid and readable in Java.
What is the main purpose of good test method naming?
✗ Incorrect
Good names help anyone reading the tests understand their purpose quickly.
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.