Home > Load Testing > Visual Studio Performance Testing Tip#3: Writing plugin

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
                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))

            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)

            //remove all dependent requests that matches the criteria
            foreach (WebTestRequest r in depsToRemove)



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.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: