Book Image

Software Testing using Visual Studio 2012

By : Subashni. S, Satheesh Kumar. N
Book Image

Software Testing using Visual Studio 2012

By: Subashni. S, Satheesh Kumar. N

Overview of this book

<p>Testing is one of the main phases in the software development lifecycle. Managing the test scenarios, test cases, defects, and linking each one of these is bit of a challenge without using any tools. For frequently changing businesses, it is essential to address testing requirements by matching the pace of the business. This can only be achieved through automation of the possible testing scenarios to reduce the turnaround time of testing.</p> <p>Software Testing Using Visual Studio 2012 is a practical, hands-on guide that provides a number of clear, step-by-step exercises, which will help you to take advantage of the new features and real power of Visual Studio 2012.</p> <p>Software Testing Using Visual Studio 2012 starts with the basics of testing types and managing the tests using Test Explorer and a few other tools. Practical examples are added to help you understand the usage of various tools and features in a better way. Software Testing Using Visual Studio 2012 is written from a developer point of view and helps you take advantage of the unit testing features and customize the tests by generating the code and fine-tuning it as per your needs. The Test Manager is a standalone tool which is part of the Visual Studio tools family and takes care of test management. Software Testing Using Visual Studio 201 covers the usage of the test plan, test suite, manual testing, and exploratory testing using Test Manger and managing these aspects using these tools.</p> <p>Software Testing Using Visual Studio 2012 also covers the recording of user actions and creating automated tests out of it. This book covers generating and adding parameters to the recording and replacing it at runtime, adding validation and extraction rules to the tests, running the tests using command line commands, looking at the details of test results, and configuring the running the load test out of web performance or unit tests.</p> <p>This book helps you to understand the complete testing features and how to make use of automation features as well. It will appeal to both developers and testers.</p>
Table of Contents (20 chapters)
Software Testing using Visual Studio 2012
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating unit tests


There are two different ways of creating unit tests. One is the manually of writing the entire code for the test, and the other is to generate the unit test code for the class using Visual Studio and customizing it. To see how a test class is generated, consider the following class library which is a very simple example of a total price calculation.

For creating a new class library in Visual Studio, click on New | Project under the File menu option and select Class Library from the available Visual C# templates.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TestLibrary
{
    public class Class1
    {
        public double CalculateTotalPrice(double quantity)
        {
            double totalPrice;
            double unitPrice;

            // Todo get unit price. For test let us hardcode it 
            unitPrice = 16.0;

            totalPrice = unitPrice * quantity;
            return totalPrice;
        }

        public...