Recall & Review
beginner
What is the main purpose of assertions in JUnit tests?
Assertions check if the actual result matches the expected result, helping confirm the code works as intended.
Click to reveal answer
beginner
How do assertions help in identifying bugs?
If an assertion fails, it shows the code did not produce the expected outcome, pointing to a possible bug.
Click to reveal answer
intermediate
Why should expected outcomes be clearly defined before writing assertions?
Clear expected outcomes ensure tests check the right behavior, making assertions meaningful and reliable.
Click to reveal answer
beginner
What happens when an assertion passes in a JUnit test?
It means the actual output matches the expected output, so the test case passes successfully.
Click to reveal answer
intermediate
Can assertions verify multiple expected outcomes in one test?
Yes, multiple assertions can check different expected results to fully verify the test scenario.
Click to reveal answer
What does an assertion in JUnit primarily verify?
✗ Incorrect
Assertions check if the actual output matches the expected output to verify correct behavior.
What happens if an assertion fails during a test?
✗ Incorrect
A failed assertion means the test fails and shows where the expected and actual results differ.
Why is it important to define expected outcomes before writing assertions?
✗ Incorrect
Defining expected outcomes helps write meaningful assertions that verify correct behavior.
Which JUnit method is commonly used to assert equality?
✗ Incorrect
assertEquals() checks if two values are equal, verifying expected vs actual results.
Can a single test method contain multiple assertions?
✗ Incorrect
Multiple assertions in one test can check various aspects of the expected behavior.
Explain why assertions are essential in verifying expected outcomes in JUnit tests.
Think about how assertions help catch errors early.
You got /4 concepts.
Describe how defining expected outcomes improves the effectiveness of assertions.
Consider the role of clarity in test design.
You got /4 concepts.