MSTest in Visual Studio 2010

There are three test categories:

-Continuous Integration Test  (that is quick test)

-Nightly Test (that is long time test)

-Manually Test

Create your unit test using MSTest:

First  create your class and methods in a console application for instance:

right click on your method and select create unit Test on the context menu:

a Create Test unit Dialog box appears and let you to specify on which method you want to create unit test, and on which test project you will create those (Output project at the bottom)

 

Select the correct Test project as follows:

 

you can also for the first time create a new test project as below:

 

another popup appears to set the name of your Test project:

in the solution, after clicking on Create button, the test project will appear in the solution explorer:

in the OperationsTest.cs file, the class test is created and you are allowed to make as unit tests you want from this template:

Create 3 tests in order to set one test by test category (CI, manually and Nightly)

In solution explorer, click on Vsmdi file, a panel on the right appears with three components:

-List of Tests : to define our test categories (empty because not defined as follows)

 

-Tests not in a list : show all tests that are not affected to a category ( all tests appear)

-All loaded tests : all tests present in the solution

we create three tests categories on right clicking on Lists of Tests and select new Test list:

a Create New Test List DialogBox appears .Create the first category , CI tests , and set the description

the new test category is visible in the Test List Editor :

repeat actions to create manually and Nightly tests:

 

assoicate unit test by drag and drop unit test showed on All Loaded Tests to the category wanted. A drag and drop of my first unit test to CI test:

 

in test list Full Name, you can read that first test is associated to CI test

 

repeat actions to associate other tests to other test categories:

if you click in a test category, you will see associated test:

 

in Test Not in a List,  there are no tests anymore because all are attached to a test category. This list is interesting, because you will see quickly new tests and you can associate it to a test category with drag and drop to List of Tests.

You can enable / disable each test on right clicking on the test and click Disable or enable in the context menu:

 

an easy way to quickly manage your unit tests. The test appear disabled:

Vsmdi file to define our list s that are categories of test

 

 

 

You can now run

 

–          each test one by one in the current context in release or debug mode

 

–          run all tests in the solution in release or debug mode

 

–          run only impacted test in release or debug mode

 

the three first shortcut are release mode, the three other are debug mode

in Test menu, select Test results view to see result of unit tests

when running test , we can see results:

 

 

Publicités

, , , , , , , ,

  1. #1 par David le octobre 16, 2012 - 1:22

    Article trés interessant

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s

Microsoft System Center 2012

All System Center 2012 products, Service Manager, App-Controller, Orchestrator, Virtual Machine Manager, Configuration Manager, Data Protection Manager, Operation Manager -Boutougha Hassan

Microsoft Windows Server 2012

IT - Windows server 2012 - Hassan Boutougha

Microsoft Hyper-V

IT - Hyper-V - Hassan Boutougha

Microsoft SQL Server 2012

IT - SQL Server 2012 - Hassan Boutougha

%d blogueurs aiment cette page :