Continuous Integration (CI) is a key practice in modern software development. Which of the following best explains why CI integration enables continuous quality?
Think about how frequent testing affects bug detection.
CI runs automated tests on every code change, which helps find bugs early. This prevents bad code from being merged and keeps the software quality high continuously.
Consider this JUnit test class run in a CI pipeline. What will be the test execution result?
import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; public class CalculatorTest { @Test void testAdd() { int result = 2 + 3; assertEquals(5, result); } @Test void testSubtract() { int result = 5 - 3; assertEquals(1, result); } }
Check the expected values in assertions carefully.
The first test checks if 2 + 3 equals 5, which passes. The second test expects 5 - 3 to be 1, but 5 - 3 is 2, so this test fails.
In a CI pipeline, you want to assert that a list returned by a method has exactly 3 items. Which JUnit assertion is correct?
import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.List; List<String> items = List.of("a", "b", "c");
Remember the order of expected and actual values in assertEquals.
assertEquals expects the first argument as the expected value and the second as the actual value. items.size() returns an int, so comparing it to 3 is correct.
Given this JUnit test run in CI, why does it fail?
import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; public class SampleTest { @Test void testCondition() { boolean condition = (5 > 10); assertTrue(condition); } }
Check the boolean condition used in assertTrue.
The condition (5 > 10) is false, so assertTrue fails and the test fails in CI.
In a CI environment using JUnit tests, what is the main reason this setup improves feedback speed for developers?
Think about how automation affects developer awareness of issues.
CI runs JUnit tests automatically on every code commit, so developers get quick feedback on whether their changes broke anything, enabling fast fixes and continuous quality.