-6

For junit tests where I am just testing if something works correctly, should I use assert(true)? Since it is legacy code, it is difficult to get a good assert statement.

3
  • 2
    I smell an XY problem. You should pick up a copy of Working Effectively with Legacy Code by Michael Feathers.
    – RubberDuck
    May 16, 2017 at 0:55
  • 2
    What exactly do you think this will accomplish? May 16, 2017 at 3:15
  • Not unless your goal is to test the correctness of the Java compiler and runtime. May 16, 2017 at 6:03

1 Answer 1

1

No. If you were to use assert(true), your always going to pass the test because True is always True.

If you want to test that it fulfills a condition using True/False, use something like assertTrue or assertFalse.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.