How to perform unit test on Sharepoint web parts

return undefined;As a programmer or developer, do you write unit test for your applications?

Did you know that a good practice when it comes to developing an application is to write the test first and ensure the test doesn’t succeed the first time. See Charles Miller’s Six Rules of Unit Testing.

Many programmers do not take the effort to write tests because of many reasons. Some find it time consuming while others feel that it’s too complicated or don’t see the end objective of unit testing.

One key benefit of unit testing is its ability to inform a programmer that his one line code change actually does cause the application to break due to code dependencies which were written by other programmers.

Application development teams that have a standard and consistent method of testing their applications usually have less fear that any new feature releases might introduce new errors. In the long run development is faster, more reliable and gives fewer problems.

There are many tools out there to help us write unit test but one that caught my attention is TypeMock.

Typemock allows your developers to write unit tests easily for .NET technologies.

Typemock distinguishes itself from other testing tools because it has test support for Sharepoint 2010.

In the past, I have written Sharepoint web parts with very little emphasis on unit testing it. Writing the web parts itself is already a daunting task and thus writing tests wasn’t a priority for us.

But without proper testing done, we find ourselves introducing new errors every time a Sharepoint web part is deployed.

It has also been mentioned on SharePointDevWiki.com that using Typemock is still the only real way to doing unit testing on Sharepoint because Typemock allows Sharepoint objects within the API to be mocked.

For more details on how to create unit testing on Sharepoint, check out this screencast by Jeremy Thake and Isolator for Sharepoint Webinar.

With so much resources and features offered by TypeMock, there’s now an easier way for you to begin unit testing Sharepoint web parts today. Enjoy!

About the author

Bob Lee

Hi! My name is Bob Lee and I’m a web developer / technical writer who specializes in developing and reviewing web applications. As an entrepreneur, blogger, developer, and tech enthusiast, I have been in this field for more than 10 years, and have been loving every minute of it.

1 Comment

Leave a Comment

/* ]]> */