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
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.
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, out number);
if (number == 0)
int data = 0;
for (int i = 2; i < number; i = i + 2)
data += i;
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.
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.