On Wed, 25 Nov 2026 03:00:56 GMT, David Holmes <[email protected]> wrote:
>> JDK-8398053: Rename assertion parameters to expected and actual >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Also could you add `[Testlibrary]` as a prefix on the JBS issue title so that > it is clear what "assertion parameters" it is referring to. > @dholmes-ora the message of the exception that was being thrown before the > fix was: > > ``` > fail((msg == null ? "assertEquals" : msg) + " expected: " + lhs + > " but was: " + rhs); > ``` > > so it seems that `lhs` was indeed the expected value and `rhs` the actual > value. Then the message is wrong/misguided. It is not generally appropriate to describe the lhs as "expected" and the rhs as actual. That would require you to write things in a very specific way which is not obvious to the user of the API. If I write: assertEquals(x,1); that seems perfectly sensible to me. But if x was 2 then the message would be "expected: 2 but was: 1" - which is totally wrong as I expected 1 but got 2. And with a more generic `assertEquals(x, y)` neither is the "expected value" they are just two values I expected to be the same. ------------- PR Comment: https://git.openjdk.org/jdk/pull/34040#issuecomment-7204499975
