Share via


How to: Run a Web Performance Test from the Command Line

This topic applies to:

Visual Studio Ultimate

Visual Studio Premium

Visual Studio Professional 

Visual Studio Express

Topic applies Topic does not apply Topic does not apply Topic does not apply

You can run your Web performance tests from the command-line. For more information, see How to: Run Automated Tests from the Command Line Using MSTest and MSTest.exe Command-Line Options.

The following procedures cover using the command-line to run Web performance tests with the following options:

  • Running a Single Web performance Test from the Command-Line

  • Running Multiple Web Performance Tests From the Command-Line

  • Running a Web Performance Test that Specifies Deployment Items

  • Running a Distributed Web Performance Test Using a Test Controller and Test Agents

  • Running a Coded Web Performance Test

  • Specifying the Results File Name

Running a Single Web performance Test from the Command-Line

To run a single Web performance test from the command-line

  1. Open a Visual Studio command prompt.

    To do this, click Start, point to All Programs, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, and then click Visual Studio 2010 Command Prompt.

    By default, the Visual Studio command prompt opens to the following folder:

    <drive letter>:\Program Files\Microsoft Visual Studio 10.0\VC

    Note

    To change the folder to which the command prompt window opens by default, click Start, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, right-click Visual Studio 2010 Command Prompt, and then click Properties. In the Visual Studio 2010 Command Prompt Properties dialog box, you can change the path to the default folder in the Start in box.

  2. Locate the folder that contains your Web performance test.

  3. To run a single Web performance test from the command-line you need to specify the /TestContainer argument. A .webtest file or .loadtest file is considered a test container and a dll which contains unit tests is also a test container. For example, If you have a Web performance test called WebTest1.webtest, you would use the following command to run the Web test:

    mstest /TestContainer:WebTest1.webtest

  4. (Optional) You can use other options with the MSTest command. For example, you can save results to a specific test results file; publish test results; or run with a specific test setting to, for example, change the files that are deployed. For more information, see MSTest.exe Command-Line Options.

Running Multiple Web Performance Tests From the Command-Line

To run a multiple Web performance tests from the command-line

  1. Open a Visual Studio command prompt.

    To do this, click Start, point to All Programs, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, and then click Visual Studio 2010 Command Prompt.

    By default, the Visual Studio command prompt opens to the following folder:

    <drive letter>:\Program Files\Microsoft Visual Studio 10.0\VC

    Note

    To change the folder to which the command prompt window opens by default, click Start, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, right-click Visual Studio 2010 Command Prompt, and then click Properties. In the Visual Studio 2010 Command Prompt Properties dialog box, you can change the path to the default folder in the Start in box.

  2. Locate the folder that contains your load test.

  3. You can specify multiple test container arguments from the command-line. If you want to execute WebTest1.webtes and WebTest2.webtest, use the following command-line:

    mstest /TestContainer: WebTest1.webtest /TestContainer: WebTest2.webtest

Running a Web Performance Test that Specifies Deployment Items

One of the big differences with running tests from the command line is that you cannot take advantage of the automatic processes in Visual Studio 2010 Ultimate. When you run a Web performance test from within Visual Studio 2010 Ultimate, Visual Studio tries to determine what needs to be deployed with the Web performance test in order for the test to run. For example, if you have written a custom validation rule or a extraction rule. When you run the Web performance test from within Visual Studio 2010 Ultimate, it will look at the references of the test project and try to figure out what needs to be deployed.

When you run tests from the command-line, you will need to be very explicit about what you deploy. For example. if you have a dll that needs to be deployed for a Web performance test to run, you will need run mstest and specify the /testsettings parameter. Test settings include deployment items. For more information, see Create Test Settings to Run Automated Tests from Visual Studio.

To run a Web performance test from the command-line that specifies deployment items contained in a test setting

  1. Open a Visual Studio command prompt.

    To do this, click Start, point to All Programs, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, and then click Visual Studio 2010 Command Prompt.

    By default, the Visual Studio command prompt opens to the following folder:

    <drive letter>:\Program Files\Microsoft Visual Studio 10.0\VC

    Note

    To change the folder to which the command prompt window opens by default, click Start, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, right-click Visual Studio 2010 Command Prompt, and then click Properties. In the Visual Studio 2010 Command Prompt Properties dialog box, you can change the path to the default folder in the Start in box.

  2. Locate the folder that contains your Web performance test.

  3. To run a Web performance test with a test setting that includes deployment information, use mstest similar to the following:

    Mstest /TestContainer:WebTest1.webtest /TestSettings:NewOrEditedTestSetting.testsettings

Running a Distributed Web Performance Test Using a Test Controller and Test Agents

When you use Visual Studio 2010 Ultimate to run a Web performance or a load test on a test controller and test agents to distribute the test across multiple machines, you need to use a test setting. In Visual Studio 2010 Ultimate you can create or edit a test setting and specify to run a controller name. For more information, see Setting Up Machines and Collecting Diagnostic Information Using Test Settings.

When you run a Web performance test from the command-line, you also need to create or use a test setting that has a test controller specified in it by using the mstest to specify the /testsettings parameter.

To run a Web performance test from the command-line that includes a test controller and test agents for distributed testing specified in a test setting

  1. Open a Visual Studio command prompt.

    To do this, click Start, point to All Programs, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, and then click Visual Studio 2010 Command Prompt.

    By default, the Visual Studio command prompt opens to the following folder:

    <drive letter>:\Program Files\Microsoft Visual Studio 10.0\VC

    Note

    To change the folder to which the command prompt window opens by default, click Start, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, right-click Visual Studio 2010 Command Prompt, and then click Properties. In the Visual Studio 2010 Command Prompt Properties dialog box, you can change the path to the default folder in the Start in box.

  2. Locate the folder that contains your Web performance test.

  3. To run a Web performance test with a test setting that includes a test controller and test agent, use mstest, similar to the following:

    Mstest /TestContainer:WebTest1.webtest /TestSettings:NewOrEditedTestSetting.testsettings

Running a Coded Web Performance Test

You can run a coded Web performance test using mstest with the /testcontainer argument set to the dll name which contains the coded test.

To run one or more coded Web performance test contained in a dll

  1. Open a Visual Studio command prompt.

    To do this, click Start, point to All Programs, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, and then click Visual Studio 2010 Command Prompt.

    By default, the Visual Studio command prompt opens to the following folder:

    <drive letter>:\Program Files\Microsoft Visual Studio 10.0\VC

    Note

    To change the folder to which the command prompt window opens by default, click Start, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, right-click Visual Studio 2010 Command Prompt, and then click Properties. In the Visual Studio 2010 Command Prompt Properties dialog box, you can change the path to the default folder in the Start in box.

  2. Locate the folder that contains your Web performance test.

  3. Run a coded Web performance test. Use mstest with the /testcontainer argument set to the dll name which contains the coded test:

    mstest /TestContainer:TestProject1.dll

    When you specify a .dll for the test container, mstest will execute all of the tests within the dll. If you want to execute just one test within a dll, you can use the /test argument. For example, to run WebTest1Coded contained in a dll, you can use the following command line:

    mstest /TestContainer:TestProject1.dll /Test:WebTest1Coded

    If you wanted to execute two Web performance tests, you can specify multiple /Test arguments:

    mstest /TestContainer:TestProject1.dll /Test:WebTest1Coded /Test:WebTest2Coded

Specifying the Results File Name

Results file (.trx file) are saved using a unique name that contains user, machine and a timestamp. If you want to specify the name of the results file and where it is generated, you can use mstest with the /resultsfile parameter.

To run specify the results file name when you run a Web performance test from the command-line

  1. Open a Visual Studio command prompt.

    To do this, click Start, point to All Programs, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, and then click Visual Studio 2010 Command Prompt.

    By default, the Visual Studio command prompt opens to the following folder:

    <drive letter>:\Program Files\Microsoft Visual Studio 10.0\VC

    Note

    To change the folder to which the command prompt window opens by default, click Start, point to Microsoft Visual Studio 2010, point to Visual Studio Tools, right-click Visual Studio 2010 Command Prompt, and then click Properties. In the Visual Studio 2010 Command Prompt Properties dialog box, you can change the path to the default folder in the Start in box.

  2. Locate the folder that contains your Web performance test.

  3. Run a coded Web performance test. Specify the name of the results file and where it is generated using mstest with the /resultsfile parameter:

    mstest /TestContainer:WebTest1.webtest /resultsfile:c:\results\MyResults.trx

See Also

Tasks

How to: Run Automated Tests from the Command Line Using MSTest

How to: Run a Load Test from the Command Line

Concepts

Running Web Performance Tests

Running Automated Tests from the Command Line

MSTest.exe Command-Line Options