Recall & Review
beginner
What does it mean for a test to be deterministic?
A deterministic test always produces the same result when run with the same input and environment, ensuring reliability and predictability.
Click to reveal answer
beginner
Why are deterministic tests important in software testing?
They help identify real bugs by avoiding false failures caused by randomness or external factors, making debugging easier and builds more stable.
Click to reveal answer
intermediate
How can you make a test deterministic when it involves random data?
Use a fixed seed for random number generators so the sequence of random values is the same every time the test runs.
Click to reveal answer
intermediate
In JUnit, what practice helps ensure tests are deterministic when dealing with time-dependent code?
Mock or control the system clock or time source so the test always uses a fixed, known time.
Click to reveal answer
beginner
What is a common cause of non-deterministic tests?
Tests that depend on external systems, network, or shared state without isolation can behave differently each run.
Click to reveal answer
What characteristic defines a deterministic test?
✗ Incorrect
Deterministic tests always produce the same result when run with the same input and environment.
How can you control randomness in a JUnit test to make it deterministic?
✗ Incorrect
Using a fixed seed ensures the random values are the same every test run.
Which of the following can cause a test to be non-deterministic?
✗ Incorrect
Using the current system time without control can cause different results each run.
Why should tests avoid depending on external systems?
✗ Incorrect
Avoiding external dependencies helps keep tests deterministic and reliable.
What is a good practice to make time-dependent tests deterministic in JUnit?
✗ Incorrect
Mocking the system clock ensures consistent time values during tests.
Explain what deterministic tests are and why they matter in software testing.
Think about tests giving the same result every time.
You got /3 concepts.
Describe strategies to make tests deterministic when they involve randomness or time.
Consider how to control variables that change each run.
You got /3 concepts.