|
.NET Unit Testing Framework
|
| Visual Studio 2008 Unit Testing Framework |
|
One of the great improvements of Visual Studio 2008 brought to developers is
the built in support for unit testing. With VS.NET 2008 Unit Testing support, it is very easy
for developer to create, execute and repeat unit test cases. Setting up a test
project in Visual Studio 2008 is extremely easy. All it requires is adding a test
project into a solution by selecting Test Project template under Test project type.
|
|
Download syllabus - Unit Testing using Visual Studio 2008 for two-day, instructor-led
course. This course provides students with the knowledge and skills to effectively use
Visual Studio 2008 to perform test driven software development. The course focuses on
applicable features and capabilities of Visual Studio and Visual Studio Team System as
related to Unit Testing and Test Driven Development (TDD). In addition, this course
introduces other, industry-standard, open-source tools and how they integrate with
Visual Studio.
|
|
-
Unit Testing Framework is integrated into Visual Studio 2008.
-
Attributes (TestMethod) are used to mark-up test classes and methods.
-
Assert class are used for checking conditions.
-
Cannot test UI elements (example: message boxes) in VS.NET 2008.
-
Create unit test cases by writing code from scratch or using a unit test wizard.
-
Step 1: Create new class representing a unit test case
-
Step 2: Create new test methods using attribute: [TestMethod()]
-
Step 3: Check some condition with Assert class static methods
-
Step 4: If the condition is false, throw a custom exception created by you!
-
Attribute ClassInitialize - run code before running the first test in the class.
-
Attribute ClassCleanup - run code after all tests in a class have run.
-
Attribute TestInitialize - run code before running each test.
-
Attribute TestCleanup - run code after each test has run.
-
There is a separate menu provided for unit testing, named Test.
-
There is a separate window at the bottom of VS.NET 2008 for Test Results.
|
| NUnit Framework |
|
NUnit
is a unit-testing framework for all .Net languages. Initially ported from JUnit, the
current production release, version 2.4, is the fifth major release of this xUnit
based unit testing tool for Microsoft .NET. It is written entirely in C# and has been
completely redesigned to take advantage of many .NET language features, for example
custom attributes and other reflection related capabilities. NUnit brings xUnit to all
.NET languages. NUnit Framework provides lot of features that will make writing test
cases easier, but has some drawbacks.
|
|
-
Installation of NUnit comes in a separate MSI.
-
No Integration with Visual Studio.
-
Requires writing test cases manually.
-
No auto generation of code.
-
Requires opening separate window (NUnit Console) to execute test cases.
-
Ordering of test cases execution not available.
-
No inbuilt feature to debug test cases.
-
No inbuilt feature to enable/disable test cases.
-
No inbuilt feature for stack trace, Trace Information etc.
-
No inbuilt feature to sort test cases based on Class Name, Host Type, etc.
|
|