ArticleDirectory
- Step 2. Create a Visual Studio project for the test code.
- Step 2. Add an nunit framework reference
- Step 2. Add a class to the project.
- Step 2. Create Your Visual Studio project and test it using nunit-Gui
- Step 2. Compile and run the test.
Test nunit Testing Tool
Copy a segmentCode, Test everything according to the code. Thank you for your tutorial.
3. How to Apply nunit in. net I will give you an example to demonstrate how to use nunit. Step 1st to create a visual Studio project for the test code. In Microsoft Visual Studio. NET, let's start creating a new project. Select Visual C # project as the project type and class library as the template. Name the project
Nunitquickstart . Figure 4-1 is a Visual Studio. NET that describes this step.
Figure 4-1: create the first nunit project Step 1. Add an nunit framework reference when creating this example in Microsoft Visual Studio. NET.
Nunit. Framework. dll Reference: Right-click the reference in Solution Explorer, select Add reference nunit. framework component, and click Select and OK in the Add reference dialog box. Figure 4-2 describes this step:
Figure 4-2: Add
Nunit. Framework. dll Reference to project Step 1. Add a class for the project. Add a class for the project
Numbersfixture Class. Here is the code for this example. 1 Using System;
2 Using Nunit. Framework;
3
4 Namespace Nunitquickstart
5 {
6 [Testfixture]
7 Public Class Numersfixture
8 {
9 [Test]
10 Public Void Addtwonumbers ()
11 {
12 Int A = 1 ;
13 Int B = 2 ;
14 Int Sum = A + B;
15 Assert. areequal (sum, 3 );
16 }
17 }
18 }
19 Step 2. Create Your Visual Studio project and use nunit-Gui to test from Program -> Nunit2.2 open nunit-Gui and load the Assembly compiled in this project.
To automatically run nunit-Gui in Visual Studio. NET, you need to create nunit-Gui as your startup program:
In Solution Explorer, right-click your nunitquickstart project.
Select properties in the pop-up menu.
On the left of the displayed dialog box, click the configuration properties folder.
Select the debugging that appears in the configuration properties folder.
In the start action section on the right of the property box, select the program in the drop-down box as the debug mode value.
Press Apply.
SetNUnit-gui.exe
As the Start application ., You can also use the Browse button to point to nunit-gui.exe.
Figure 4-3 help describe this step :
Figure 4-3:
Use nunit-Gui as the test runner of the project
Step 2. Compile and run the test. Compile solution now. After compilation, start the application. Nunit-Gui test runner appears. When you first start nunit-Gui, it does not test loading when it is opened. Select oprn from the File menu and browse
Nunitquickstart .
DLL . When you load the tested assembly, the test runner produces a visible performance for the testing of the loaded assembly. In this example, the test assembly has only one test. The structure of the test assembly is 4-4:
Figure 4-4: Test assembly test view in nunit-Gui press the run button. The node of the tree turns green, and the progress bar on the test runner window turns green. Green indicates that the node passes successfully.
From http://www.cnblogs.com/confach/archive/2005/06/20/177817.html
Only for record
Additional resources
Quikstart http://www.cnblogs.com/confach/archive/2005/06/20/177817.html
Http://www.36sign.com/nunit/ tutorial
Http://nunit.com/index.php? P = download