Unit Testing Using Visual Studio 2010
page 1 of 5
Published: 05 Apr 2011
Unedited - Community Contributed
Abstract
This article will demonstrate how to use Visual Studio 2010 to develop, run, and maintain unit tests.
by Vince Varallo
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 27812/ 54

Introduction

One of the steps all good developers take when developing an application is unit testing.  Unit testing involves testing a single method or function to ensure it is behaving as expected.  From what I've seen through real life experience is that when a developer initially develops his or her method they thoroughly unit test it. However, when changes are made for a new release I've seen the process fall apart.  A lot of time developers make the change that was requested and only test the scenario that was requested without going back to make sure other scenarios didn't break.  I'm guilty of this myself.

Visual Studio has a great unit testing framework which can help solve this problem.  You can build  unit testing scripts, which are essentially classes that call your code that you can then execute to determine if you're code is working correctly.  When you make an enhancement or re-factor your code you can simply run the unit test scripts to determine that the code is still functioning properly. It will take you extra time to initially develop your code but it is worth the investment knowing that your code is working correctly and that you can more easily maintain your code with confidence.

This article will show you how to create an ASP.NET application and how to unit test the ASP.NET web page and a public class in a class project.  It will also demonstrate how to execute your unit tests individually or in a group. The code for this sample can be found here.


View Entire Article

User Comments

Title: 404 on link to code for this sample   
Name: Chase
Date: 2012-11-29 1:40:46 PM
Comment:
I am getting a 404 when I click the link for the code for this sample. I'd love to try this!
Title: unit testing   
Name: Avinash Chowdary
Date: 2012-06-01 8:03:30 AM
Comment:
good article and what about the asp.net web applications they don't have .Dll to refer in test project can you explain this scenario
Title: nice one   
Name: Abhishek goletar
Date: 2012-04-16 6:18:05 AM
Comment:
nice article
thks
Title: Positive Feedback   
Name: Hitesh
Date: 2012-04-16 6:15:45 AM
Comment:
very best example to undesrstand.
I like it very much..
Thank you !!!!
Title: nice article   
Name: gourik
Date: 2011-05-03 5:02:26 AM
Comment:
thanks..
Title: unit testing   
Name: nitin garg
Date: 2011-04-06 9:00:54 PM
Comment:
good article. expecting to dive deeper in next article by creating more complex test cases.
Title: Unit Testing   
Name: wasim
Date: 2011-04-06 2:00:12 PM
Comment:
awesome.
Title: Unit Testing Answer   
Name: Vince Varallo
Date: 2011-04-06 9:16:41 AM
Comment:
The purpose of unit testing is to validate that the code you wrote performs as expected. In this example the CalculateDistance method has a few different expected results depending on the parameters that were passed in. As a developer you should test all of the expected results. If at a later date you make a change to the method you still need to validate that all of the expected results are being produced. This tool allows you to automate the process of testing your code so it should be easier to maintain and ensure the application is working as expected.
Title: Unit Testing   
Name: Dhairya Shukla
Date: 2011-04-06 2:10:55 AM
Comment:
It's good understand for me, but If you can describe what is the purpose of unit testing in asp.net and how can use it.
One more think is that explain in basic and simple language






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-24 5:31:15 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search