This post is going to be a bit advanced. If you're having trouble with understanding any of the below information - you can ask in the comments section or post in our technical forum. Or if you're a paying/trial user you can submit a support ticket requesting additional assistance.
Ok, so as you may or may not be aware we allow you to extend Test Studio's functionality through plugins. This article gives you a nice breakdown of how you can do that. And as you can see in that article the functionality you're allowed to extend is mostly related to functional testing and data-driven testing. As of this writing our Latest Internal Build is 2012.2.1022. And with this build we've extended the plug-in capabilities to include Load testing. Writing a Load testing plugin works in pretty much the same way except that you need to implement a different set of interfaces. Where as this article talks about a class that implements the IExecutionExtension interface, this time you will need to implement one or all three of the following interfaces (the rest of it works the same way):
Each of these comes with its own set of functions that will allow you to extend the way Load testing works. Let's say that you want Test Studio to create a new, randomly-named file every time it create a new Virtual User during Load testing. I know that's a silly example but you should be able to get the idea. The code is seen below. The code overrides all the extendible Load functions - I included that so that you may have some idea of what's extendible. But I've only given VirtualUserAllocated an implementation. The rest of them don't do anything. Don't worry that they throw an exception - it will not affect your Load testing inside of Test Studio. One last thing - you'll need an Assembly Reference to Telerik.TestStudio.Load.Common.dll. Without further ado here's the code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Data; using System.Data.OleDb; using System.Windows.Forms; using ArtOfTest.WebAii.Design.Execution; using Telerik.TestStudio.Load.Interfaces.Load.API; namespace ClassLibrary1 { public class Class1 : ILoadAgentPlugin, ILoadAgentPluginHttpRequest, ILoadAgentPluginVirtualUser { public void VirtualUserAllocated(Guid userProfileId, Guid virtualUserId) { Random random = new Random(); int randomNumber = random.Next(0, 5000); File.Create("c:\\test\\" + randomNumber.ToString()); } public void VirtualUserDeallocated(Guid userProfileId, Guid virtualUserId) { throw new NotImplementedException(); } public void AfterResponseReceived(Guid virtualUserId, int currentStepIndex, System.Net.HttpWebResponse response) { throw new NotImplementedException(); } public void BeforeRequestSent(Guid virtualUserId, int currentStepIndex, System.Net.HttpWebRequest request) { throw new NotImplementedException(); } public string OverrideOutgoingUrl(Guid virtualUserId, int currentStepIndex, string url) { throw new NotImplementedException(); } public void UserProfileAllocated(Guid profileRunID, string profileFriendlyName) { throw new NotImplementedException(); } } }