Testing tooling
JUnit assertEquals
Checks equality under the selected overload. Framework or debugger behavior source-reviewed; actual tool execution NOT RUN.
Formal Syntax & Structure
java syntaxjava
assertEquals(expected, actual)Working Example
Example Snippetjava
package example.books;
import org.junit.jupiter.api.Test;import org.junit.jupiter.api.BeforeEach;import static org.junit.jupiter.api.Assertions.*;
class ReceiptTest { private int price;
@BeforeEach void setUp() { price = 250; }
@Test void multipliesCountByPrice() { assertEquals(750, Receipt.totalCents(3, price)); }
@Test void rejectsNegativeCount() { assertThrows(IllegalArgumentException.class, () -> Receipt.totalCents(-1, price)); }}