Skip to content

Comment on Ask HN: doesn't runtime exceptions and unit tests share the same goal?

Comments

Couldn't the ifs have other purpose, such as branching to perform other operations in those cases?

Also, consider that if the entire block isn't wrapped in a try/catch, those ifs are guarding against runtime errors which would crash the program for the user.

Although I do see unit tests making use of exceptions in their decision to pass/fail, it's not the only way to write a unit test-- sometimes you test for value, etc.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.