We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Writing a test case that expects an exception thrown is a better approach than one that expects the exception message. I'm not very familiar with HackerRank so this may not be possible, but it's not a good practice to force the developer to catch an exception that was going to be thrown anyway for the sake of testing.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Exception Handling (Try-catch)
You are viewing a single comment's thread. Return to all comments →
Writing a test case that expects an exception thrown is a better approach than one that expects the exception message. I'm not very familiar with HackerRank so this may not be possible, but it's not a good practice to force the developer to catch an exception that was going to be thrown anyway for the sake of testing.