Is Unit Testing Essential for Every Piece of Production Code?

0
14
Asked By CuriousCoder42 On

I'm curious about the necessity of testing for each unit of production-ready code. For instance, there's a GitHub project that I came across, and it seems like it only has tests for semantic versioning. To me, that feels somewhat trivial compared to the various functions within the game. Am I missing something here? When exactly are tests regarded as essential for production-ready code?

6 Answers

Answered By CodeMaster99 On

Definitely! Sometimes, changes that seem minor can actually break things unexpectedly. For example, Tomcat switched its default timing from milliseconds to nanoseconds, and it caused issues in Spring logging. It’s a reminder that even small changes can have big impacts.

Answered By QualityGuard12 On

I refuse to approve any pull requests unless they come with full unit test coverage for all business logic and, ideally, integration tests too. In a professional environment, shipping without at least that is unacceptable. But I understand that in legacy systems, testing can be a challenge.

Answered By CodeNavigator56 On

Having tests that cover every possible code branch helps ensure that edge cases won’t slip through the cracks. Plus, unit tests can significantly simplify the process of identifying where a bug might be, instead of digging deep later on during high-level testing.

Answered By DevSage88 On

Not every project requires unit tests for everything, so it's a "no" for mandatory tests. However, I usually aim for 100% line coverage in my own projects.

Answered By TestPilot22 On

You don't need to test every single line, but it's crucial to have enough tests to ensure that new code doesn't break existing features.

Answered By BugSeeker77 On

Over time, you'll develop a gut feeling for how much testing is sufficient. You might write too many tests at first and waste time, or you might skimp on them and then end up spending days tracking down tricky bugs.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.