junit-team / junit4

A programmer-oriented testing framework for Java.
https://junit.org/junit4
Eclipse Public License 1.0
8.53k stars 3.29k forks source link

Fix "ReturnValueIgnored" errors flagged by error-prone #1719

Closed kluever closed 2 years ago

bhuvanaindukuri commented 2 years ago

Which version of java were you able to replicate this issue? Also isn't it better to replace the line e.getMessage(); with either assertTrue(true); or just remove the statement altogether as done in other methods like "testAssertNullNotEqualsString"

kluever commented 2 years ago

Which version of java were you able to replicate this issue?

At Google, we've enabled CheckReturnValue by default, so all non-void APIs that are not annotated with @CanIgnoreReturnValue must have their values used. This has caught thousands of bugs so far, and we hope to be open sourcing this soon!

kcooney commented 2 years ago

@bhuvanaindukuri if you send me a pull request doing that I would approve it. Alternately we could have the code assert that the message contained a string.

Note these tests are very old. They verify the JUnit 3.x assertion code

kcooney commented 2 years ago

Asking @marcphilipp or @sbrannen to provide a second approval, then I can merge.