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.
-
2I smell an XY problem. You should pick up a copy of Working Effectively with Legacy Code by Michael Feathers.– RubberDuckMay 16, 2017 at 0:55
-
2What exactly do you think this will accomplish?– candied_orangeMay 16, 2017 at 3:15
-
Not unless your goal is to test the correctness of the Java compiler and runtime.– Kilian FothMay 16, 2017 at 6:03
Add a comment
|
1 Answer
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.