Organizations often increase the size and scope of their test suites as their software grows. What is the main reason for this scaling?
Think about how software complexity affects the chance of bugs.
As software grows, more features and interactions appear. Scaling test suites helps catch bugs early and maintain quality.
What is the output of this JUnit test suite execution?
import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; public class SampleTest { @Test void testAddition() { assertEquals(5, 2 + 3); } @Test void testSubtraction() { assertEquals(1, 3 - 2); } @Test void testFailure() { assertEquals(4, 2 * 3); } }
Check the expected and actual values in each assertion.
The first two tests have correct assertions and pass. The third test expects 4 but 2*3 is 6, so it fails.
Which JUnit assertion correctly verifies that an object reference is null?
JUnit provides a specific assertion method for null checks.
assertNull is the dedicated assertion to check if an object is null. Others work but are less clear or idiomatic.
A large JUnit test suite sometimes fails randomly on a test that reads a shared file. What is the most likely cause?
Think about what happens when multiple tests access the same resource.
Sharing mutable state like files without isolation can cause race conditions and flaky tests.
Which approach best helps scale a large JUnit test suite to run faster without losing test coverage?
Think about how to use modern JUnit features to speed up tests.
JUnit supports parallel test execution to reduce total runtime while keeping coverage intact.