SSW Update - Do you know what unit tests to write and how many?
Microsoft Gold Partner Logo


[ the cutting edge ]

G'Day Developers!

Do you know what unit tests to write and how many?

People aim for 100% Unit Test Coverage but in the real world this is 100% impractical. Actually it seems that the most popular metric in TDD (Test Driven Development) is to aim for 100% of methods to be unit tested. However in the real world this goal is rarely, if ever, achieved. Unit tests are created to validate and assert that public and protected methods of a class meet an expected outcome based on varying input. This includes both good and bad data being tested, to ensure the method behaves as expected and returns the correct result or traps any errors.

Generally, private methods should not have unit tests written for them as they are not exposed to other objects outside the original class. These private methods are likely to be refactored (eg. changed, renamed) over time and will require the unit tests to be updated and this becomes a maintenance nightmare. So how do private methods get tested? Private methods should be tested by the unit tests on the public and protected methods calling them and this will indirectly test the private method behaves as intended.

Eg. You would test correct input such as 12/3 = 4 plus bad input such as 12/4 <> 4 and that 12/0 does not crash the application, and instead a DivideByZero Exception is thrown and handled gracefully.
Eg. Methods returning a Boolean value need to have both true and false test cases.

See more Rules to Better Unit Tests

Merry Christmas and a Happy New Year!

SSW Chief Architect and Microsoft Regional Director, Australia

Got a comment for Adam? 6164616d636f67616e407373772e636f6d2e6175.

Sydney .NET User Group -
The best place to learn .NET for free in Sydney

User Group

1 day to go!

Sydney .NET User Group
Wednesday 19th December 2007
5:45pm - 9:00pm
Microsoft, Sydney

Windows Workflow Foundation

Adam Cogan and Mark Liu will be introducing Windows Workflow Foundation. We will discuss some real world scenarios, go over the architecture of the framework, and talk about some common problems people may face when adopting this new technology.

See You There!! | Sorry I can't make it

Featured Service: SSW SQL Deploy

Have your application automatically deploy schema changes to your backend SQL Server with SSW SQL Deploy

SSW SQL DeployHow many times have you deployed an initial version of your SQL Server or MSDE Database application to your clients or departments, then wondered how you are going to make updates to the Database schema in the future without hassle?

SQL Deploy solves this problem by automatically performing Database updates as a part of your application deployment. Bundle SSW SQL Deploy when you distribute a new version of your application to clients and all your database changes will happen automatically.

More on SSW SQL Deploy

Merry Christmas from SSW

Merry Christmas!From all the staff at SSW we would like to wish you a very Merry Christmas and a Happy New Year. May you enjoy a festive season with your families and keep safe. See you in 2008.
A little fun from the SSW Team.

SSW will be closed on the following dates:

» Tuesday 25th Dec 2007
» Wednesday 26th Dec 2007
» Tuesday 1st January 2008

Advertise with SSW

If you would like to advertise your product or service with SSW or would like to find out more about different advertising opportunities, please email your enquiries to info@s* or call: +61 2 9953 3000.

Proudly developed by SSW Sydney Web Design