TestDriven.NET – quick start

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

TestDriven.NET – The rapid entry n.

Introduction

This section provides a quick start wizard, use the TestDriven in any version of the vs.NET. NET

TDD(Test Driven Development) before you write your code, write unit tests is a is a habit. Write unit tests before you write the code, the test can make you better understand your intentions and goals. TDD (Test Driven Development) also encourages code coverage, not only can improve the quality of the code, also allows you to reconstruct some inner classes or methods, rapid and simple test of external object interface.

TestDriven.NET is a VS plug-in unit test. He used the original name of NUnitAddIn has been developed for many years. It supports multiple unit testing framework includes NUnit, MbUnit and MSTS and all versions of VS.NET compatible. Personal version and commercial version can exert its effect.

Installation

TestDriven.NET can use admin or restricted users to install. By default to the current user installation. Due to limited user is not on the Program Files folder access, The installation will be carried out in the current user of the'Application Data\TestDriven.NET'folder. Administrator users will install files to the'Program Files\TestDriven.NET' folder. The default folder you can choose to'Custom'change in this page'Choose Setup Type'

TestDriven.NET according to the different functions are packed into NUnit and MbUnit two Framework. unit testing it also contains an executive in the VSTS unit test adapter. They will be under the'TestDriven.NET'folder. (as shown in Figure 1)

Figure 1: . TestDriven.NET Setup

Perform test

After installation finished, restart TestDriven.NET VS,'Run Test (s) 'command (within, in the range of test code and click the mouse) provides a fast compile test channel. Test methods for conducting it will by default. It will automatically be detected to test framework is used and execute test cases current. The test will be the test engine with an external process. This process will be carried out later, can improve the test execution times. Once a test process is captured, a rocket (Rocket) the icon will prompt box.

If the code editor option is selected, the test will be performed at the location of the cursor is terminated by. When you right-click on any one method of internal, there 'RunTest (s) each individual test will be performed (Figure 2). Right click on the 'Run Test' (s) when, all tests will be performed in a namespace are. 'Run Test (s) 'button and also in'Solution Explorer' was found. It can be used to execute the project in a solution, project, or in item test.

Figure 2 Run Test(s) menu item

Random testing

Random test provides a useful alternative to abandon a command-line program. They are in any case can not replace the real unit test. Of course, they will want to provide a convenient local private method in third versions.

Any method can simply by right clicking on the 'Run Test' was executed as a random test. He can be public, private, static instance. Any method can be executed as an ad-hoc test simply by right-clicking inside it and selecting 'Run test(s)'. It can be a 'public', 'private', 'static' or 'instance' Method. Instance method, When you use the default constructor., An object will be created. When a test is executed, the Dispose method will be realized when the IDisposable interface by calling.

If a random test returns a nibble, output panel this parameter will expand to 'Test'. Complex objects tell a domain and their attributes are displayed. Countable objects will be listed. The original object will be converted to a string and will be displayed. When using the 'Debug.WriteLine', the same results will also be included.

The test output & test list

The output of the'Test'panel will be a window, here can see the results of all tests and warning information (Figure three). Together with the command line output and error information, tracking and debugging information will also be sent, if all the test execution. In a project or solution, test output frame will only display the ignored or did not pass the test.

When a test fails, the test names together will be abnormal information and tracking the queue are displayed. If the code is compiled with some debugging information, calculate travel the same number of stack trace information will. Double click the part will be a master Ze the messy code is very good method.

Figure 3 Output Test Pane

Like sending output panel information, testing the nursery rhymes wrong will be added to the task list. If a test fails, then this will be a very useful summary view (Figure 4) generally speaking, further up the stack, speaking from will interest is very interesting. Double click the test area the task list is another way to enter the code.

Figure 4 Task list view

Using the Debugger test

'Test With'The menu offers many alternative content can be performed in the test. Select the Debugger'content can perform the test in vs debugging. By adding the power method and choose'Test With Debugger' can enter a unit test.

Figure 5 Test With Debugger

The default case VS will set up all of the items in a solution, when they use debugger to perform. In VS2003 and 2005 in " Only build options; startup projects and dependencies on Run". After the selected can reduce the increase compilation time for big solutions. In VS2003, this option is'Environment / Projects and Solutions'. Vs05 can be found in the following'Projects and Solutions / Build and Run'.

Testing items of & solution

By right clicking on the'Solution Explorer'window, select the'Run Test (s)', in all tests will be performed in project. Failure or testing will be ignored by sending'Test'output window and the task list, in a style similar to that of the'Run Test (s)' command. If the track in a project or solution, all of the test execution, debug and command-line output is prohibited,

Similarly, all solutions of test will in a solution in the right click on 'Solution Explorer' in the window and choose'Run Test (s). The framework will be in each of the projects in a solution test was used to establish and test time using the correct test was performed when. The project does not contain any test will be ignored

The termination of a running test

When a test is being performed, the menu'Abort Test'options will appear in the'Tools' menu (Figure 6). Will stop an executing thread after selecting an option. When the test end in this way, any logic will be cleared for a chance of implementation.

Figure 6 Abort Test

Stop the test process

In some cases it is necessary to stop some test process. The most common is when a app domain was established, but has not been loaded into a test to. It can lead to any load to the app domain in an assembly that is locked, any subsequent compilation will fail. Right click on the icon in the notification box and select 'stop' can be used circularly testing process (Figure 7). A new test process will be the next time you use 'Run Test' (s) command was executed.

Figure 7 Stopping the Test Process

The original address

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Francis at November 14, 2013 - 11:48 AM