Test Overview
This test checks if a number is positive using assertTrue and if a number is negative using assertFalse. It verifies that the conditions about the number's sign are correct.
This test checks if a number is positive using assertTrue and if a number is negative using assertFalse. It verifies that the conditions about the number's sign are correct.
import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; public class NumberSignTest { @Test public void testNumberSign() { int number = 5; assertTrue(number > 0, "Number should be positive"); int negativeNumber = -3; assertFalse(negativeNumber > 0, "Number should not be positive"); } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | JUnit test runner is ready to execute the test method | - | PASS |
| 2 | Assign number = 5 | Variable 'number' holds value 5 | - | PASS |
| 3 | assertTrue(number > 0) | Check if 5 > 0 | Verify condition 'number > 0' is true | PASS |
| 4 | Assign negativeNumber = -3 | Variable 'negativeNumber' holds value -3 | - | PASS |
| 5 | assertFalse(negativeNumber > 0) | Check if -3 > 0 | Verify condition 'negativeNumber > 0' is false | PASS |
| 6 | Test ends successfully | All assertions passed | - | PASS |