Visual Studio : Generic Test

Ambily.raj
Posted by in Visual Studio category on for Intermediate level | Points: 250 | Views : 9733 red flag

Visual studio supports various tests to perform the test automation and performance test. We already discussed about the Web test and Load test features. In this article we will discuss more about the Generic test feature of Visual Studio 2010.

 

Visual studio supports various tests to perform the test automation and performance test. We already discussed about the Web test and Load test features. In this article we will discuss more about the Generic test feature of Visual Studio 2010

Generic Test

When we need to do a performance test of an application, first we need to generate the test scripts using Unit Test or Web Test. After the test script generation, we will add the test scripts to the load test to do the performance test. But, in some cases the creation of test scripts won’t be possible.

For example, we need to do a performance test of an executable. In this case, we will use the Generic Test. Generic test is a wrapper over an executable or dll and make it as testable. Once, we wrap our executable or dll using generic test, we can add the generic test to Load test and will perform the performance test.

Sample Executable

For our sample, I added a console application. Inside main method, I am getting the first argument and try to parse it as integer. If the argument is not an integer or zero, it will return the value 1; otherwise will perform some operation and return the value as 0.  If the Generic test receives any value other than 0, it fails the test. If it receives 0 as the return value from the executable, it will pass the test. 
 

static int Main(string[] args)

        {

            int number = 0;

            Int32.TryParse(args[0], out number);

            if (number == 0)

                return 1;

 

            int data = 0;

            for (int i = 2; i < number; i = i + 2)

            {

                data += i;

            }

            return 0;

        }


Generic Test

Right click on the test project and select Add -> Generic Test. 
 

 

Once added, it opens the generic test configuration. Specify the executable file, command line arguments and dependency files here.



Run the Test

Now, run the test using Test View Window. In our sample, if we pass a non-numeric value or zero as command line argument the test will fail; otherwise it will pass.

Now add the Generic test to Load test to perform the performance test of our executable.

Summary

Visual Studio supports the performance testing of an executable by using the Generic test feature. Generic test wraps the executable and make it as a test script, which can be used by Load test framework.

 

Page copy protected against web site content infringement by Copyscape

About the Author

Ambily.raj
Full Name: Ambily KK
Member Level: Silver
Member Status: Member,Microsoft_MVP,MVP
Member Since: 5/18/2010 1:05:25 AM
Country: India
Thanks Ambily K K http://ambilykk.com/
http://ambilykk.com/
I have over 9 years of experience working on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Office Open XML, Azure, Visual Studio 2010. Technology adoption and learning is my key strength and technology sharing is my passion.

Login to vote for this post.

Comments or Responses

Posted by: Madhu.b.rokkam on: 2/15/2011 | Points: 25
Good one :)
Posted by: Karthikanbarasan on: 2/15/2011 | Points: 25
Nice article to start with...
Posted by: Samarmir on: 2/15/2011 | Points: 25
Nice article, thanks!

Login to post response

Comment using Facebook(Author doesn't get notification)