Étiquettes

, , , ,

Visual Studio Application Lifecycle Management (ALM) solution enables businesses to manage the entire life of the application development, reduce cycle times and eliminate waste in order to provide a continuous stream of business value.

When effectively implemented, ALM practices break down barriers between teams, enabling organizations to meet the challenges and to provide high quality software at a faster pace Companies using ALM also benefit from a greater reduction of waste, faster cycle times and greater agility.

During application development , it essential to answer the following questions:

  1. What is the probability of my application to crach ?
  2. Will my Infrastructure  be able to stand in front of a large amount of users?
  3. When  integrating a new software component , is it possible to have  negative impact on the existing one? .

In this tutorial, we are going to walk through 3 steps:

  • Validate and maintain the quality of our application through the unit tests. Next, we switch to using a test driven development (TDD) approach in which we write unit tests before writing the production code.
  • Simulate user load on a web application
  • Validate and maintain the quality of our application through the unit tests

We have different types of tests :

  1. C. Web Performance Testing
  2. D. Load Testing
  3. E. Code Coverage
  4. F. Ordered tests
  5. G. Testing and Team Foundation Server

A. Getting Started

There are actually many profiles of potential testers : all project developers will not have to perform load tests or web tests, this task is delegated to a small group of people.

We are using visual studio 2012 so as to be able to cover a large number of test case.

In contrast, people who perform unit tests will be more numerous..

It is therefore imperative to conduct a battery of tests to different aspects of the application. To identify gaps in earlier and be able to work their corrections cost, this exercise should take place throughout the development process.

B. Unit tests

Unit tests verify that every part of our application responds correctly to the functional requirements that have been expressed and it has no bug. Throughout the development of the application, re-running the tests automatically (when generating build as seen in the previous chapter) or when editing the corresponding module, we can ensure that we non-regression system.
Since Visual Studio 2005, Microsoft proposes using MSTest, its own testing framework, fully integrated into the IDE. The principle is simple: the attributes are used to decorate classes and methods and have written assertions. This is the conclusion of the latter indicate that if our test is passed or not.
In the following example, we will use the Authenticate class below. We will add it in a Project Class Library in the solution:

  • Create a project class Library and add our class Authenticate as a sample for testing.

public class Authenticate
{
public Authenticate(string email, string password)
{
this.Email = email;
this.Password = password;
}

private string _email;

public string Email
{
get { return _email; }
private set
{
string errorMessage;
if (!IsValidEmail(value, out errorMessage))
{
throw new ArgumentException(errorMessage);
}

_email = value;
}
}

private string _password;
public string Password
{
get { return _password; }
private set
{
string errorMessage;
if (!IsValidPassword(value, out errorMessage))
{
throw new ArgumentException(errorMessage);
}
_password = value;
}
}

public static bool IsValidPassword(string value,out string errorMessage)
{
errorMessage = string.Empty;
if(string.IsNullOrWhiteSpace(value))
{
errorMessage = « Password may not be null or empty. »;
return false;
}
return true;
}
public static bool IsValidEmail(string email, out string errorMessage)
{
if (string.IsNullOrWhiteSpace(email))
{
throw new ArgumentException(« Parameter email may not be null or empty. »);
}

errorMessage = « Your adress email is incorrect »;
Regex regex = new Regex(@ »^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$ »);
Match match = regex.Match(email);
if (match.Success)
{
return true;
}
return false;
}

public void ChangePassword(string oldPassword, string newPassword)
{
if (oldPassword == Password)
{
Password = newPassword;
}
else
{
throw new ArgumentException( « The old password was not correct. »);
}
}
}

  • Next Add Project Unit Test as follow

UnitTest1

  • Now Create a UnitTest

UnitTest2

The first thing we will do is to test our constructor

UnitTestind1

It is very simple to write the test  : we pass parameters such as emai  and password and verfy that the values affected by the constructor and parameters are same.

Generally, we pass arguments to our methods, we get the result and check that it is consistent with what was expected

UnitTestind2

  • To run test, right click method name and choose appropriate test

UnitTestind3

  • We can also, open test explorer as follow

UnitTestind4

  • In test explorer Window, we have the result of our test but also many options. We let you discover them

UnitTestind5

We can also analyse Code Coverage so as to determine if all our code path is covered by our test case

UnitTestind6

We let you discover the streaming video ( surrounding red ) wich present briefly unit testing

UnitTestind7

C. Web Performance Testing

D. Load Testing

E. Code Coverage

F. Ordered tests

G. Testing and Team Foundation Server

The completed  article is coming soon . Please fill the form below to be get notifed