- MSTest
MSTest is a software unit testing framework developed by
Microsoft , which integrates closely withVisual Studio . MSTest lets you create, manage and run unit tests from within the Visual Studio IDE, as well as externally, from thecommand line .MSTest Design
The MSTest framework has a design that is familiar to those who have worked with
NUnit in the past.Test Class
Test classes are declared as such by decorating a class with the [http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testclassattribute(VS.80).aspx TestClass attribute] . The attribute is used to identify classes that contain test methods. Best practices state that test classes should contain only unit test code.
Test Method
Test methods are declared as such by decorating a unit test method with the [http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testmethodattribute(VS.80).aspx TestMethod attribute] . The attribute is used to identify methods that contain unit test code. Best practices state that unit test methods should contain only unit test code.
Assertions
An assertion is a piece of code that is run to test a condition or behavior against an expected result. Assertions in MSTest are executed by calling methods in the [http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.assert(VS.80).aspx Assert class] .
Initialization and Cleanup Methods
Initialization and cleanup methods are used to prepare unit tests before running and cleaning up after unit tests have been executed. Initialization methods are declared as such by decorating an initialization method with the [http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testinitializeattribute(VS.80).aspx TestInitialize attribute] , while cleanup methods are declared as such by decorating a cleanup method with the [http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testcleanupattribute(VS.80).aspx TestCleanup attribute] .
ample Test
Below is a very basic sample unit test:
ee Also
*Software Testing
*Unit Testing
*Test Driven Development
*NUnit
*List of Unit Testing FrameworksExternal links
* [http://msdn.microsoft.com/en-us/library/ms379625(VS.80).aspx A Unit Testing Walkthrough with Visual Studio Team Test]
* [http://weblogs.asp.net/rosherove/archive/2008/01/17/the-evolution-of-unit-testing-and-syntax.aspx The evolution of Unit Testing Syntax and Semantics]
* [http://www.xprogramming.com/testfram.htm Kent Beck's original testing framework paper]
* [http://The.ArtOfUnitTesting.com/ Roy Osherove's book excerpts on Unit Testing: The Art Of Unit Testing]
* [http://www.softdevarticles.com/modules/weblinks/viewcat.php?cid=34 List of articles on unit testing]
* [http://shebanation.com/2007/08/21/a-brief-history-of-test-frameworks/ History of unit test frameworks (Andrew Shebanow)]
* [http://www.parasoft.com/jsp/redirector.jsp/WWH_UnitTesting_W Why, When, How: Unit Testing white paper (Adam Kolawa)]
* [http://geosoft.no/development/unittesting.html Unit Testing Guidelines from GeoSoft]
* [http://c2.com/cgi/wiki?TestDrivenDevelopment Test Driven Development (Ward Cunningham's Wiki)]
Wikimedia Foundation. 2010.