Choose the best reason why fast tests lead to more frequent test runs by developers.
Think about how waiting time affects your willingness to check your work.
Fast tests provide quick feedback, which encourages developers to run them often and catch problems early.
Given the following JUnit test code, what will be printed when the test runs?
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; public class SpeedTest { @Test void testFast() throws InterruptedException { long start = System.currentTimeMillis(); Thread.sleep(50); // simulate fast test long duration = System.currentTimeMillis() - start; System.out.println("Test duration: " + duration + " ms"); assertTrue(duration < 100); } }
Look at the sleep time and the assertion condition.
The test sleeps for 50 ms, so duration is about 50 ms, which is less than 100 ms, so the assertion passes.
Choose the correct JUnit assertion to verify a test method completes in less than 200 milliseconds.
long duration = measureTestDuration(); // returns test duration in msThink about how to check a value is less than a limit.
assertTrue(duration < 200) correctly checks the duration is under 200 ms with a clear message.
Consider this JUnit test that measures execution time. Sometimes it fails when run with other tests. Why?
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; public class TimingTest { @Test void testDuration() throws InterruptedException { long start = System.currentTimeMillis(); Thread.sleep(100); long duration = System.currentTimeMillis() - start; assertTrue(duration < 150, "Test took too long"); } }
Think about what happens when many tests run at once on the same machine.
When many tests run together, CPU or resource contention can slow tests, making timing assertions fail.
Choose the best explanation of how fast tests benefit CI pipelines in software projects.
Think about how test speed affects developer workflow and integration speed.
Fast tests shorten CI pipeline duration, enabling quicker feedback and faster integration of code changes.