Tuesday, April 13, 2021

Happy Little JUnit Test

Woman saying "your JUnit test passes no matter the input" with man replying "it's a happy test!"

 My husband and I were talking about testing and this scenario came to mind. The purpose of a JUnit test is to test a small area of your code. It should only pass if the code is doing what it is suppose to be doing - you should be able to change the input and see the test fail. Then you can design extra tests to verify that giving wrong or garbage input throws the expected exception. But if your happy path test passes no matter what you input, that's not really doing anything for you. 

Text:
L: Your JUnit test is useless - it never fails, no matter the input.
C: It's a happy test!

No comments:

Post a Comment

Thank you for commenting! Your comment is awaiting moderation and will show up once approved.