Test Overview
This test checks that two strings are not equal using assertNotEquals in JUnit. It verifies that the actual output differs from an incorrect expected value.
This test checks that two strings are not equal using assertNotEquals in JUnit. It verifies that the actual output differs from an incorrect expected value.
import static org.junit.jupiter.api.Assertions.assertNotEquals; import org.junit.jupiter.api.Test; public class NotEqualsTest { @Test public void testStringsAreNotEqual() { String actual = "Hello World"; String wrongExpected = "Hello Jupiter"; assertNotEquals(wrongExpected, actual, "Strings should not be equal"); } }
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | JUnit test runner initialized | - | PASS |
| 2 | Runs testStringsAreNotEqual method | Method execution begins | - | PASS |
| 3 | Assigns actual = "Hello World" | Variable actual holds "Hello World" | - | PASS |
| 4 | Assigns wrongExpected = "Hello Jupiter" | Variable wrongExpected holds "Hello Jupiter" | - | PASS |
| 5 | Calls assertNotEquals(wrongExpected, actual, "Strings should not be equal") | Comparing "Hello Jupiter" and "Hello World" | Verify that wrongExpected != actual | PASS |
| 6 | Test completes successfully | No exceptions thrown | - | PASS |