This section provides a 'Quickstart' guide to using TestDriven.NET any version of Microsoft Visual Studio.NET



Similar documents

Gallio: Crafting a Toolchain. Jeff Brown jeff.brown@gmail.com

To install Multifront you need to have familiarity with Internet Information Services (IIS), Microsoft.NET Framework and SQL Server 2008.

Developing, Deploying, and Debugging Applications on Windows Embedded Standard 7

Appendix K Introduction to Microsoft Visual C++ 6.0

Pipeliner CRM Phaenomena Guide Add-In for MS Outlook Pipelinersales Inc.

Section 1: Ribbon Customization

SaaS Encryption Enablement for Customers, Domains and Users Quick Start Guide

WINDOWS PROCESSES AND SERVICES

How to test and debug an ASP.NET application

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

INSTALLATION INSTRUCTIONS FOR UKSSOGATEWAY

Setting Up Peak Performance Group Policies

DEPLOYING A VISUAL BASIC.NET APPLICATION

For Introduction to Java Programming, 5E By Y. Daniel Liang

CodeWarrior Development Studio for Freescale S12(X) Microcontrollers Quick Start

FIGURE Selecting properties for the event log.

Composite.Community.Newsletter - User Guide

NETWRIX CHANGE NOTIFIER

Sharpdesk V3.5. Push Installation Guide for system administrator Version

Introduction to Eclipse

Download and Installation Instructions. Java JDK Software for Windows

There are 2 approaches to starting a session: the mutation scope can contain a whole codebase or in a single chosen method.

Introduction to the use of the environment of Microsoft Visual Studio 2008

Macintosh: Microsoft Outlook Web Access

Xcode Project Management Guide. (Legacy)

Using Group Policies to Install AutoCAD. CMMU 5405 Nate Bartley 9/22/2005

Upgrade Guide BES12. Version 12.1

Exclaimer Alias Manager for Exchange Deployment Guide - Exclaimer Alias Manager for Exchange Outlook Add-In

Spambrella SaaS Encryption Enablement for Customers, Domains and Users Quick Start Guide

Debugging Java Applications

Using Microsoft Visual Studio API Reference

COMMANDS 1 Overview... 1 Default Commands... 2 Creating a Script from a Command Document Revision History... 10

NetWrix Password Manager. Quick Start Guide

How to install and use the File Sharing Outlook Plugin

Integrated Virtual Debugger for Visual Studio Developer s Guide VMware Workstation 8.0

3 IDE (Integrated Development Environment)

ScanWin Installation and Windows 7-64 bit operating system

Releasing blocked in Data Security

FlexSim LAN License Server

New in this release: On-Demand Sync. Known Issues: Limitations: Previous version features:

SMS for Outlook. Installation, Configuration and Usage Guide

Code::Blocks Student Manual

STATISTICA VERSION 10 STATISTICA ENTERPRISE SERVER INSTALLATION INSTRUCTIONS

Configuring Load Balancing

Remote Desktop Services User's Guide

How do I find my Outlook 2007 mailbox quota?

Getting Started with CodeXL

On premise upgrade guide (to 3.3) XperiDo for Microsoft Dynamics CRM

What's New in ADP Reporting?

Programming with the Dev C++ IDE

AJ Matrix V5. Installation Manual

You can find the installer for the +Cloud Application on your SanDisk flash drive.

Creating, Running, and Scheduling Scripts

LAB: Enterprise Single Sign-On Services. Last Saved: 7/17/ :48:00 PM

WinSCP for Windows: Using SFTP to upload files to a server

Administration Guide. . All right reserved. For more information about Specops Deploy and other Specops products, visit

Installing OneStop Reporting Products

Test Automation Integration with Test Management QAComplete

Windows Server Update Services 3.0 SP2 Step By Step Guide

MS SQL Express installation and usage with PHMI projects

How To Install Outlook Addin On A 32 Bit Computer

Richmond SupportDesk Web Reports Module For Richmond SupportDesk v6.72. User Guide

Outlook Web App (Online)... 3 Outlook 2013 (Desktop) Apple Mail Mobile Devices Android iphone... 40

Monitoring SQL Server with Microsoft Operations Manager 2005

Composite.Community.Newsletter - User Guide

CRM Setup Factory Installer V 3.0 Developers Guide

Inteset Secure Lockdown ver. 2.0

Argus Direct add-in for spreadsheets - Installation Guide

Nexsure Training Manual - Admin. Chapter 11

XF Extracellular Flux Analyzer. Installation and Troubleshooting Guide

Known Issues and Work Around

For Active Directory Installation Guide

Install SQL Server 2014 Express Edition

HyperFS PC Client Tools

VirtualXP Users Guide

Compute Cluster Server Lab 3: Debugging the parallel MPI programs in Microsoft Visual Studio 2005

Interact for Microsoft Office

Cluster to Cluster Failover Using Double-Take

Virtual Office Remote Installation Guide

Android Application Development: Hands- On. Dr. Jogesh K. Muppala

Dream Report Version 4.5

Getting Started with the Ed-Fi ODS and Ed-Fi ODS API

Symantec Enterprise Vault

Walkthrough: Creating and Using an ASP.NET Web Service in Visual Web Developer

FileMaker Server 14. Network Install Setup Guide

Symantec Enterprise Vault

Developing In Eclipse, with ADT

Create, Link, or Edit a GPO with Active Directory Users and Computers

Crystal Reports. For Visual Studio.NET. Designing and Viewing a Report in a Windows Application

Moving the Web Security Log Database

DeviceLock Management via Group Policy

Troubleshooting Guide

Exchange Server Backup and Restore

Section 5 Icons and Shortcuts

Using the Synchronization Client

Issue Tracking Anywhere Installation Guide

Demo: Controlling.NET Windows Forms from a Java Application. Version 7.3

Transcription:

Quickstart TestDriven.NET - Quickstart TestDriven.NET Quickstart Introduction Installing Running Tests Ad-hoc Tests Test Output Test With... Test Projects Aborting Stopping Introduction This section provides a 'Quickstart' guide to using TestDriven.NET any version of Microsoft Visual Studio.NET Test Driven Development is the practice of writing unit tests for your code before you actually write that code. By writing a test and then writing the code to make that test pass you have a much better idea of what the goal and purpose of your code is. Test Driven Development also encourage complete code coverage, which not only increases the quality of your code, but also allows you to refactor the internals of a method or class and quickly and easily test the outside interface of the object. TestDriven.NET is a unit testing add-in for Visual Studio. It was developed for a number of years under the name NUnitAddIn. It supports multiple unit testing frameworks including NUnit, MbUnit, csunit and MS Team System and is compatible with all versions of Visual Studio.NET. It is available in free and (in the future) professional versions. Installing TestDriven.NET can be installed using an administrator or limited user account. By default it will install for just the current user. Because limited users don't have write access to the 'Program Files' folder, a limited user installation will install files in user's 'Application Data\TestDriven.NET' folder. An administrator installation will install files in the 'Program Files\TestDriven.NET' folder. These defaults can be changed by selecting 'Custom' on the 'Choose Setup Type' page. TestDriven.NET is packaged with functional versions of the NUnit and MbUnit unit testing frameworks. It also includes an adaptor for executing Visual Studio Team System unit tests when available. These will be installed to subdirectories inside the 'TestDriven.NET' directory as shown in Figure 1. Figure 1. TestDriven.NET Setup Run Test(s) After installing TestDriven.NET, and re-starting Visual Studio, the 'Run Test(s)' command (available on the Right- Click context menu) offers a straightforward way to build and run tests. It is intended to be the default method of test execution in most contexts. It automatically detects the test framework being used and executes tests using

the correct test runner. The tests are launched by a test execution engine running as an external process. This test process is kept alive in order to improve execution times on subsequent runs. Once a test process has been cached, a rocket icon will appear in the notify box. If the code editor window is selected, the test(s) to execute will be determined by the position of the caret; individual tests are executed by right-clicking anywhere inside a test method and selecting 'Run Test(s)' as shown in Figure 2; all tests in a test fixture are executed by right-clicking inside a class (but outside of any method) and selecting 'Run Test(s)'; all tests in a namespace are executed by right-clicking inside a namespace and selecting 'Run Test(s)'. The 'Run Test(s)' button is also found on various 'Solution Explorer' context menus. It can be used to execute all tests in a solution, project or project item. Figure 2. Run Test(s) menu item Ad-Hoc Tests Ah-hoc tests offer a useful alternative to throw away console applications. They should not in any way act as a substitute for real unit tests. Rather, they are intended to provide a convenient way of exploring local private methods or 3rd party code. Any method that does not take parameters 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. In the case of an 'instance' method, an object will be created using the default constructor of the class (providing, of course, that the class has a default constructor). The 'Dispose' method will be called on any object that implements 'IDisposable', once the test has been executed. If an ad-hoc test returns an argument, the argument will be expanded to the 'Test' output pane. Complex objects will have their fields and properties displayed. Enumerable objects will be listed. Primitive objects will be converted to strings and displayed. The same result can be obtained by using 'Debug.WriteLine(ob, "_verbose")'. Test Output & Task List The 'Test' output pane is the window in which all test results and warning messages appear and is shown in Figure 3 (below). Trace and debug information is also sent there, along with console output and error messages. If all tests in a project or solution are being executed, the test output pane will only display ignored or failed tests. When a test fails, the name of the test together with the exception message and stack trace is displayed. If code has been compiled with debugging information, the corresponding portions of the stack trace will contain line numbers. Double -clicking on these portions is a convenient way of navigating to the offending code.

Figure 3. Output Test Pane As well as sending information to the output pane, failing tests also get added to the task list. If many tests have failed, this creates a useful summary view as shown in Figure 4 (below). Generally, the further up the stack trace, the more likely the code will be of interest. Double-clicking on a test in the task list is an alternative way of accessing the code in question. Figure 4. Task list view Test With... Debugger The 'Test With ' menu offers many alternative contexts in which to run tests. Selecting the 'Debugger' context executes test(s) with the Visual Studio debugger attached as shown in Figure 5 (below). By setting a breakpoint on a method and selecting 'Test With Debugger' it is possible to step into a unit test.

Figure 5. Test With Debugger By default Visual Studio will build all projects in a solution when executing with the debugger. In Visual Studio.NET 2003 and 2005 there is an option to, "Only build startup projects and dependencies on Run". Checking this option can significantly improve startup times when debugging large solutions. In Visual Studio.NET 2003 this option is under 'Environment / Projects and Solutions'. In Visual Studio 2005 it can be found under 'Projects and Solutions / Build and Run'. Test Projects & Solutions By right-clicking on a project in the 'Solution Explorer' window and selecting 'Run Test(s)', all tests within that project will be executed. Failed and ignored tests are sent to the 'Test' output pane and task list in a similar fashion to other 'Run Test(s)' commands. Trace, debug and console output is suppressed when executing all tests in a project or solution. Similarly, all tests in a solution can be executed by right-clicking on the solution in the 'Solution Explorer' window and selecting 'Run Test(s)'. For each project in the solution the test framework being used is established and tests are executed using the correct test runner. Projects that do not contain any tests are simply ignored. Aborting a Test Run When a test run is in progress an 'Abort Test' menu item will appear on the 'Tools' menu as shown in Figure 6 (below). Selecting this item will abort the thread the tests are executing on. When tests are aborted in this way, any cleanup logic is given a chance to run. Figure 6. Abort Test Stopping the Test Process There are some circumstances in which it is necessary to stop the test process. The most common of these is when an app domain is created, but not unloaded by a test run. This can result in any assemblies loaded by the app domain being locked, and subsequent builds failing. It is possible to recycle the test process by right-clicking on the rocket icon in the notify box and selecting 'Stop' as shown in Figure 7. A new test process will be launched the next time the 'Run Test(s)' command is executed.

Figure 7. Stopping the Test Process Jamie Cansdale, 2004, TestDriven.NET author.