-5

I have a question regarding this programming code I get the following error message

assertTrue(true);

Error [PMD]: This assertion uses only values known at compile time, so it cannot test any useful behavior exhibited by your code at run-time.

Do you know what I can do to fix this code so it does not show it again

Linus Fernandes
  • 498
  • 5
  • 30
omegaprime12
  • 11
  • 1
  • 3

1 Answers1

6

I don't know exactly what the context is for your code, but true is always true, and assertTrue's job is to check if something is true.

Since your asserting that true is true, you are not doing anything practical and the test is pointless. PMD is reporting to you that your test does nothing. (i.e. It is technically valid Java code, just pointless code).

Presumably, you can just remove that line. If this is in a test, it should be replaced with a test that can actually potentially be true or false.

CeePlusPlus
  • 803
  • 1
  • 7
  • 26