Visual Studio Performance Testing #6: User login Script


In the previous post, I showed how to instruct the tool to use a new user every time it executes a test iteration. But that might not be what you need when running your load test. Most of my load testing gigs have the following requirement:

-I want x number of users to login to the system

-I want those users to run the following test cases until the completion of the test duration

In other words, users should login once and keep executing test cases.

To fulfil the requirements, we need to create two scripts: one for login the user and the other contains the requests for the scenarios

In the load test file, right click on the scenario and click Edit Test Mix

At the bottom of the dialog, check “Select an initialize test to execute before other tests for each virtual user” and select the Login script. Your other scenarios should be at the middle of the dialog where my CreateCompany script is.

About Lajak Technologies

A consulting firm in Ottawa, Ontario that provides services related to Microsoft technologies, Team Foundation Server, DevOps practices, security and more. Contact us today to help you solving your complex software problems. Visit us at http://www.lajak.com.

Advertisements

Visual Studio Performance Testing #5: New User Per Test Iteration While Load Testing


While running a load test, Visual Studio or Test Agents iterate though the recorded requests. After the requests are completed, the tool will re-execute the requests using the same virtual user and session.

To change the default behavour and tell the tool to use a new user per test iteration you need to set the Percentage of New Users to 100

About Lajak Technologies

A consulting firm in Ottawa, Ontario that provides services related to Microsoft technologies, Team Foundation Server, DevOps practices, security and more. Contact us today to help you solving your complex software problems. Visit us at http://www.lajak.com.

Visual Studio 2017 Live Unit Tests


One of the best features in Visual Studio 2017 is Live Unit Tests. It allows you to see the lines of code that are covered by unit tests and the result of running those unit tests. Live unit tests also update the results of the unit tests and the lines on the code on the modification of the code without manually running the unit tests. By click on the red X icon on the left, you can see which unit test(s) are failing and you can quickly jump to it to fix it. The – icon indicates that the line is not covered by any unit tests. Live unit test supports MSTest, NUnit, and XUnit using C# and VB.NET.

 

For more info about Life Unit Tests, visit https://blogs.msdn.microsoft.com/visualstudio/2017/03/09/live-unit-testing-in-visual-studio-2017-enterprise/

About Lajak Technologies

A consulting firm in Ottawa, Ontario that provides services related to Microsoft technologies, Team Foundation Server, DevOps practices, security and more. Contact us today to help you solving your complex software problems.

Visual Studio 2017 Gets a New Start Page


 

One of the new features in Visual Studio 2017 is the new Start Page. As shown below, it looks spacious and everything is at your finger tip. Notice on the right-hand side, you can collapse the news feed if you are not interested in that. On the left-hand side, the recent solutions is grouped by This month Last month and Older. To the right of that, you can open a new project from VSTS, or from a local folder without using the menus. Finally, you can create a new project by using one of the recent project templates or search for a project template without using the dialog.

About Lajak Technologies

A consulting firm in Ottawa, Ontario that provides services related to Microsoft technologies, Team Foundation Server, DevOps practices, security and more. Contact us today to help you solving your complex software problems.

Visual Studio Performance Testing Tip #4: Plugin is not executing


In the previous post, I showed how to create a plugin for Visual Studio Performance Test to suppress dependent requests that contained certain text. In few occasion the plugin wasn’t being executed by Visual Studio. I tried many things include, GACing the assemblies, Copy to local drive, reboot and other solutions that are posted on the internet. But nothing fixed the issue.

I found out that removing the requests that invoke favicon.ico fixed the issue. I don’t know reason. It seems to be a bug

About Lajak Technologies

A consulting firm in Ottawa, Ontario that provides services related to Microsoft technologies, Team Foundation Server, DevOps practices, security and more. Contact us today to help you solving your complex software problems. Visit us at http://www.lajak.com.

Visual Studio Performance Testing Tip#3: Writing plugin


One of the websites I had to perform a performance and load test was behind a firewall and it wasn’t connected to the internet. But, the website was doing calls to googleAnalytics and other Analytics tools. I wrote a plugin to suppress dependent requests that contains certain text. The following is the source code of the plug in which was part of a Class Library project.

using Microsoft.VisualStudio.TestTools.WebTesting;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LoadTestingPlugins
{
    public class FilterDependentRequest : WebTestPlugin
    {
        string m_containsRequests;
        //Property that is visible in the WebTest Plugin property window. User can enter comma separated phrases for suppress multiple requests
        public string FilterOutDependentRequestsThatCotains
        {
            get { return m_containsRequests; }
            set { m_containsRequests = value; }
        }

        List m_FilterDependentRequests;
        List FilterDependentRequests
        {
            get
            {
                if (m_FilterDependentRequests == null)
                {
                    m_FilterDependentRequests = new List(FilterOutDependentRequestsThatCotains.Split(','));

                }
                return m_FilterDependentRequests;
            }
        }
        public override void PostRequest(object sender, PostRequestEventArgs e)
        {
            if (string.IsNullOrEmpty(FilterOutDependentRequestsThatCotains))
            {
                return;
            }

            WebTestRequestCollection depsToRemove = new WebTestRequestCollection();
            //loop through the dependent request
            foreach (WebTestRequest r in e.Request.DependentRequests)
            {
                //Save request that contains any of the comman separated phrases into a temp array
                if (FilterDependentRequests.FirstOrDefault(s => r.Url.Contains(s)) != null)
                {
                    depsToRemove.Add(r);
                }
            }

            //remove all dependent requests that matches the criteria
            foreach (WebTestRequest r in depsToRemove)
            {
                e.Request.DependentRequests.Remove(r);
            }

        }

    }
}

About Lajak Technologies

A consulting firm in Ottawa, Ontario that provides services related to Microsoft technologies, Team Foundation Server, DevOps practices, security and more. Contact us today to help you solving your complex software problems. Visit us at http://www.lajak.com.

Visual Studio Performance Testing Tip#2: Extract a value by Id


I do few performance testing gigs a year. One of the most frequently think I do is extracting a value of an element by id from the response of a request. The extracted value is used in subsequent requests

For example, let’s say I go www.lajak.com and there is a HTML element declared as follows:

<input id=”testId” value=”testValue” />

There few ways to extract the value of the input. The most reliable way to extract the value using Visual Studio is to use the “Extract Attribute Value” Extraction Rule.

Right click on the request you want to extract the value from its response and click on Add Extraction Rule

Select Extract Attribute Value

Enter a Context Parameter Name

Tag Name is “input” which is the name of the element

Match Attribute name is the name of the attribute we want to search by. In our example, we are trying to an element’s value by id. Hence the value of the property is id

Match Attribute value is the value of the above attribute. In our example, the value is testid

Attribute name, is the attribute name that we want get its value. In our example it is value

The above extraction rule should extract “testValue” and save it into TestIdValue.

In subsequent requests, bind to your querystring or form to TestIdValue parameter

About Lajak Technologies

A consulting firm in Ottawa, Ontario that provides services related to Microsoft technologies, Team Foundation Server, DevOps practices, security and more. Contact us today to help you solving your complex software problems. Visit us at http://www.lajak.com.