Commit eb1b7ec9 eb1b7ec90450b9225e0f9a28f8bc35a315ad7556 by Christian Gerdes

New WebTest Plugin: AddParameterToReportingName

1 parent f9846f3e
......@@ -23,6 +23,37 @@ using Microsoft.VisualStudio.TestTools.LoadTesting;
namespace LIL_VSTT_Plugins
{
[DisplayName("Add Parameter To Reporting Name")]
[Description("This request plugin will add the specified parameter to the end of the reporting name of the request")]
public class AddParameterToReportingName : WebTestRequestPlugin
{
[DisplayName("Parameter Name"), DefaultValue(""), Description("Name of the parameter which value should be added to the reporting name.")]
public string ParameterName { get; set; }
[DisplayName("Add to empty Report Name"), DefaultValue(false), Description("The parameter value will be added to report name even if it not set. Warning, will also set all redirects to the same name.")]
public bool AddToEmptyReportName { get; set; }
[DisplayName("Run on dependent requests"), DefaultValue(false), Description("The parameter value will be set as the report name on all dependent requests (only works in loadtests)")]
public bool RunOnDependents { get; set; }
public override void PreRequest(object sender, PreRequestEventArgs e)
{
base.PreRequest(sender, e);
if (e.WebTest.Context.ContainsKey(ParameterName) && (!String.IsNullOrEmpty(e.Request.ReportingName) || AddToEmptyReportName))
{
e.Request.ReportingName = e.Request.ReportingName + e.WebTest.Context[ParameterName].ToString();
}
}
public override void PostRequest(object sender, PostRequestEventArgs e)
{
base.PostRequest(sender, e);
if (RunOnDependents && e.WebTest.Context.ContainsKey(ParameterName))
{
foreach (WebTestRequest w in e.Request.DependentRequests)
{
w.ReportingName = e.WebTest.Context[ParameterName].ToString();
}
}
}
}
[DisplayName("Stop Here After")]
[Description("Add this plugin to a request in order to force the webtest to stop after the request has finished.")]
public class StopHereAfter : WebTestRequestPlugin
......
......@@ -35,6 +35,7 @@
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<RunCodeAnalysis>false</RunCodeAnalysis>
<NoWarn>1692;0618;3021</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.LoadTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
......
......@@ -344,7 +344,6 @@ namespace LIL_VSTT_Plugins
{
if (e.ResponseExists && (int)e.Response.StatusCode >= 500) e.Request.Outcome = Outcome.Fail;
WebTestRequestCollection depsToRemove = new WebTestRequestCollection();
foreach (WebTestRequest r in e.Request.DependentRequests)
{
......