architecture-samples icon indicating copy to clipboard operation
architecture-samples copied to clipboard

Tests should use `assertEquals` for consistency

Open dturner opened this issue 2 years ago • 1 comments

dturner avatar Mar 27 '23 10:03 dturner

Here’s a concise and effective response or resolution strategy for Issue #932 – "Tests should use assertEquals for consistency":

Issue Summary Inconsistent test assertions are used throughout the codebase — some tests may use assertThat(), assertTrue(), or raw comparisons, while others use assertEquals().

Using assertEquals(expected, actual) improves readability, IDE formatting, and error messages during test failures.

Recommended Fix Refactor test assertions to:

import org.junit.Assert.assertEquals

// Instead of: assertTrue(result == expected) assertThat(result, is(expected))

// Use: assertEquals(expected, result) Example Before → After Before:

assertTrue(user.name == "Alice") After:

assertEquals("Alice", user.name) Benefits Improves consistency across the test suite.

Easier failure debugging with clear diff in messages.

Standardizes best practices (especially in JUnit-based projects).

VaradGupta23 avatar Jul 15 '25 13:07 VaradGupta23