New WebTest Plugin: AddParameterToReportingName
Showing
5 changed files
with
32 additions
and
1 deletions
| ... | @@ -23,6 +23,37 @@ using Microsoft.VisualStudio.TestTools.LoadTesting; | ... | @@ -23,6 +23,37 @@ using Microsoft.VisualStudio.TestTools.LoadTesting; |
| 23 | 23 | ||
| 24 | namespace LIL_VSTT_Plugins | 24 | namespace LIL_VSTT_Plugins |
| 25 | { | 25 | { |
| 26 | [DisplayName("Add Parameter To Reporting Name")] | ||
| 27 | [Description("This request plugin will add the specified parameter to the end of the reporting name of the request")] | ||
| 28 | public class AddParameterToReportingName : WebTestRequestPlugin | ||
| 29 | { | ||
| 30 | [DisplayName("Parameter Name"), DefaultValue(""), Description("Name of the parameter which value should be added to the reporting name.")] | ||
| 31 | public string ParameterName { get; set; } | ||
| 32 | [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.")] | ||
| 33 | public bool AddToEmptyReportName { get; set; } | ||
| 34 | [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)")] | ||
| 35 | public bool RunOnDependents { get; set; } | ||
| 36 | public override void PreRequest(object sender, PreRequestEventArgs e) | ||
| 37 | { | ||
| 38 | base.PreRequest(sender, e); | ||
| 39 | if (e.WebTest.Context.ContainsKey(ParameterName) && (!String.IsNullOrEmpty(e.Request.ReportingName) || AddToEmptyReportName)) | ||
| 40 | { | ||
| 41 | e.Request.ReportingName = e.Request.ReportingName + e.WebTest.Context[ParameterName].ToString(); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | public override void PostRequest(object sender, PostRequestEventArgs e) | ||
| 45 | { | ||
| 46 | base.PostRequest(sender, e); | ||
| 47 | if (RunOnDependents && e.WebTest.Context.ContainsKey(ParameterName)) | ||
| 48 | { | ||
| 49 | foreach (WebTestRequest w in e.Request.DependentRequests) | ||
| 50 | { | ||
| 51 | w.ReportingName = e.WebTest.Context[ParameterName].ToString(); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 26 | [DisplayName("Stop Here After")] | 57 | [DisplayName("Stop Here After")] |
| 27 | [Description("Add this plugin to a request in order to force the webtest to stop after the request has finished.")] | 58 | [Description("Add this plugin to a request in order to force the webtest to stop after the request has finished.")] |
| 28 | public class StopHereAfter : WebTestRequestPlugin | 59 | public class StopHereAfter : WebTestRequestPlugin | ... | ... |
| ... | @@ -35,6 +35,7 @@ | ... | @@ -35,6 +35,7 @@ |
| 35 | <Prefer32Bit>false</Prefer32Bit> | 35 | <Prefer32Bit>false</Prefer32Bit> |
| 36 | <CodeAnalysisRuleSet>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> | 36 | <CodeAnalysisRuleSet>C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\Rule Sets\MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> |
| 37 | <RunCodeAnalysis>false</RunCodeAnalysis> | 37 | <RunCodeAnalysis>false</RunCodeAnalysis> |
| 38 | <NoWarn>1692;0618;3021</NoWarn> | ||
| 38 | </PropertyGroup> | 39 | </PropertyGroup> |
| 39 | <ItemGroup> | 40 | <ItemGroup> |
| 40 | <Reference Include="Microsoft.VisualStudio.QualityTools.LoadTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> | 41 | <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 | ... | @@ -344,7 +344,6 @@ namespace LIL_VSTT_Plugins |
| 344 | { | 344 | { |
| 345 | 345 | ||
| 346 | if (e.ResponseExists && (int)e.Response.StatusCode >= 500) e.Request.Outcome = Outcome.Fail; | 346 | if (e.ResponseExists && (int)e.Response.StatusCode >= 500) e.Request.Outcome = Outcome.Fail; |
| 347 | WebTestRequestCollection depsToRemove = new WebTestRequestCollection(); | ||
| 348 | 347 | ||
| 349 | foreach (WebTestRequest r in e.Request.DependentRequests) | 348 | foreach (WebTestRequest r in e.Request.DependentRequests) |
| 350 | { | 349 | { | ... | ... |
No preview for this file type
No preview for this file type
-
Please register or sign in to post a comment