When we develop any website or app, it is required to check its performance before launching it to the production or live environment. Performance load testing checks the website ability to perform under anticipated user loads. The main objective of load testing is to identify performance bottlenecks before the application goes live. With this, we can find out the performance issues or problems before the end user faces it and report that to us.
Pre-requisites
To perform load testing we need to have the following:
- Visual Studio 2017 Enterprise edition, it can be downloaded here, if not already installed.
- A VSTS account, we can create our account here, if the account is not already created. Any access level will work to perform/run load test using Visual Studio Enterprise.
Connecting to VSTS
To create and run the load test in a cloud, connect Visual Studio to a VSTS account
- Go to Team Explorer and click Manage Connection and then Connect to a project
Figure 1 Connecting to VSTS – Team Explorer
- The Manage connection popup will display the list of repositories which have been already added to the visual studio previously. We can add our account by clicking Add an account option and providing credentials.
- Now it will connect to our VSTS account and will display a list of VSTS repositories associated with that account.
- Select the VSTS account repository which is to be used from the list and select the team project, then click Connect.
Figure 2 Connecting to VSTS – Add account and select team project
Now the Visual studio is connected to the VSTS account, we can start creating the load test project
Creating a load test project
- In Visual Studio create a new project using “Web performance and Load test project” template placed inside Test projects templates as below
Figure 3 Create Load test project
If we cannot find this template in Visual Studio, it means it is not installed. In this case, we need to install the web performance test template project. Follow below steps to install this
- Run the Visual Studio 2017 Installer
- Switch to Individual Component tab and open Debugging and testing section
- Check “Web performance and load testing tools” option
Now we can find the test template in Visual Studio and can create the project.
- Open the file with the extension “. webtest” (it will be opened automatically when a project is created)
- Right click on WebTest à click Add Request. It will add a request with localhost as shown in the image below:
Figure 4 Add request in the web test
Figure 5 Web test request URL
- We can replace the localhost URL with our actual website URL in the Request properties window as below
Figure 6 Request properties
- We can also add Validation rules for the web test, right-click WebTest project and then
click Add Validation Rule
- Specify the rules and properties in the next screen and click OK
Figure 8 Add Validation rule in web test -2
- We can see the web test as below
Figure 9 Webtest
- Now Right click the project and Add a Load test
Figure 10 Add Load test in the project
- It will open the New load test wizard to specify the load test settings, we can select the type of load test whether it will be cloud-based or On-premise load test and click Next to specify the other settings.
Figure 11 Set load test type
- We can select the Azure data center location from where the load will be generated. It should be selected considering the user’s location, we can select the location which is closer to the users of the website and click Next
Figure 12 Set load test location
- We can specify the run settings like test duration or iterations and click Next
Figure 13 Set test duration and Iteration
- It contains a list of scenarios which can be added to the load test like Load pattern, Browser mix or test mix and click Next
Figure 14 Set test load pattern
- On this screen we can specify the test mix like how the test will be executed, based on total number of tests or Virtual users etc. and click Next
Figure 15 Set test model behavior
- We can add the tests here which are previously created, the tests will have the web request URL.
- Select the test
- Move it to the selected tests area
- Click OK
Figure 16 Add web tests to the test
- We can specify browsers to test the performance, we can add multiple browsers and can set the distribution ratio for the load test with different browsers.
Figure 17 Add browsers to perform the test with
- Click Finish and it will create the Load test, we can check and edit the test properties from the properties window as below
Figure 18 Load test
Run the load test
Now as we have created the load test, so we can run the load test to test the website performance with the parameters specified at the time of load test creation like duration, a number of users, browser etc.
- Right-click on the Run setting and click Run Load Test, it will run in the Cloud using VSTS
Figure 19 Run load test
- It will build the solution and will start initializing the load test as below.
Figure 20 Load test In-Progress
- It shows the progress and performance of the Graph and details tab. We can check the website performance when the test is running, we can also check for errors, warnings, and information about the test.
Figure 21 Load test showing performance graph
- It displays Completed status when the test is 100% done. It shows the Performance graph and other details in the test result, we can also Download the test report or can open the Web report in VSTS portal to view the test results.
Figure 22 Load test with the result
The test results include performance counter data, threshold violations, and error information. We can review the test result and can find out the number of users where the website performance is not good.
We can fix the performance issues and can run the test again before deploying the website to production to ensure the website launch with high performance.