import static org.junit.jupiter.api.Assumptions.assumingThat; import static org.junit.jupiter.api.Assertions.assertEquals; boolean isFeatureEnabled = true; assumingThat(isFeatureEnabled, () -> { assertEquals(5, 2 + 3); }); System.out.println("Test completed");
The assumingThat method runs the assertion only if the condition is true. Here, since isFeatureEnabled is true, the assertion assertEquals(5, 2 + 3) runs and passes. The test completes successfully and prints "Test completed".
import static org.junit.jupiter.api.Assumptions.assumingThat; import static org.junit.jupiter.api.Assertions.assertEquals; boolean isFeatureEnabled = false; assumingThat(isFeatureEnabled, () -> { assertEquals(5, 2 + 2); }); System.out.println("Test completed");
When the condition is false, assumingThat skips the assertion inside the lambda. So the assertion assertEquals(5, 2 + 2) is not executed. The test continues and prints "Test completed". The test passes because no assertion failed.
Option D correctly uses .equals("prod") to compare the environment variable string. Option D uses == which compares references, not string content, so it may fail. Option D only checks for non-null but does not check the value. Option D uses equalsIgnoreCase which is not exactly the requirement.
boolean isReady = false; assumingThat(isReady = true, () -> assertEquals(1, 2));
The condition uses isReady = true which is an assignment, not a comparison. This sets isReady to true and returns true, so the assertion runs and fails. To check equality, use isReady == true or simply isReady.
When the condition in assumingThat is false, the entire lambda block is skipped. None of the assertions inside run, so no failures or logs occur from them.