This is a mirror of official site: http://jasper-net.blogspot.com/

10 Reasons to Write Unit Tests

| Monday, December 19, 2011
I came across this great list of 10 reasons to write unit tests. It’s an old post, but still very good points. Want to get started unit testing? Typemock is hosting a webinar about how to start on Wednesday, December 7. Join us!

Here are one person’s thoughts.

    Don’t let your customers discover embarassing bugs. Write tests to cover a multitude of scenarios and catch these bugs before they get into production.
    Test complex scenarios quickly, without having to manually reproduce them in the application.
    By testing often, you don’t break the application as you go. You can’t always know the indirect implications of what you’re writing, especially if you didn’t write the original application.
    By testing early, you don’t write unnecessary code but only the strict necessary. This makes the codebase smaller and more maintainable. It also saves on development time.
    You do not have to debug the same code twice. Once you have a test to account for a possible bug, you’ll pick up any wrong turns quickly.
    You ensure readability. A unit test makes the purpose of your code easier to understand.
    You ensure maintainability. Unit-testing forces you to better encapsulate functionality, thus making it easier to maintain and add new features.
    Refactor without worries. Run the tests to make sure everything still functions as intended.
    Save time on testing. You can test the entire application at the speed of your CPU.
    Feel safer. How many times were you afraid to add a new feature or change something in your application’s core? No more!
    Bonus: know exactly what is broken. Instead of hunting for an obscure bug, let the tests tell you what’s wrong and why. Example: the application will tell you when you add an item to a cart but the cart still appears empty. It will also tell you what item you tried to add for the cart to break.

What are yours? (And, of course, don’t forget to comment on Anna’s blog as well).

Read more: Typemock.net
QR: http://chart.googleapis.com/chart?chs=80x80&cht=qr&choe=UTF-8&chl=www.typemock.com/blog/2011/11/28/10-reasons-to-write-unit-tests/

Posted via email from Jasper-net

0 comments: