Recall & Review
beginner
What is the purpose of assumptions in JUnit tests?
Assumptions in JUnit tests check if certain conditions are true before running the test. If the assumption fails, the test is skipped instead of failed.
Click to reveal answer
beginner
How do assumptions affect test execution flow?
If an assumption is false, JUnit stops running that test and marks it as skipped. This prevents false failures when the test environment is not suitable.
Click to reveal answer
beginner
Example of a JUnit assumption statement
Assume.assumeTrue(condition); // If condition is false, test is skipped.
Click to reveal answer
intermediate
Why is skipping tests with failed assumptions better than failing them?
Skipping tests avoids confusion by showing that the test was not run due to unmet conditions, rather than showing a failure caused by wrong setup.
Click to reveal answer
intermediate
What happens if you don't use assumptions and environment conditions are not met?
Tests may fail incorrectly, causing wasted time debugging issues that are actually due to wrong environment or setup, not the code itself.
Click to reveal answer
What does JUnit do when an assumption fails during a test?
✗ Incorrect
When an assumption fails, JUnit skips the test to avoid false failures.
Which JUnit method is used to check assumptions?
✗ Incorrect
Assume.assumeTrue() is the standard method to check assumptions in JUnit.
Why should tests be skipped instead of failed when environment conditions are not met?
✗ Incorrect
Skipping prevents false failures caused by unsuitable test conditions.
What happens if you use Assert.assertTrue() instead of Assume.assumeTrue() for environment checks?
✗ Incorrect
Assert.assertTrue() causes test failure if the condition is false, unlike Assume.assumeTrue() which skips.
Which scenario is a good use case for assumptions in tests?
✗ Incorrect
Assumptions help run tests only when environment matches, like Windows OS.
Explain why assumptions are important to control test execution in JUnit.
Think about what happens if environment is not right for the test.
You got /4 concepts.
Describe the difference between Assert.assertTrue() and Assume.assumeTrue() in JUnit testing.
Focus on how each affects test result when condition is false.
You got /4 concepts.