Added Report Name Automator (needs more testing though)
Showing
2 changed files
with
72 additions
and
0 deletions
... | @@ -323,6 +323,72 @@ namespace LIL_VSTT_Plugins | ... | @@ -323,6 +323,72 @@ namespace LIL_VSTT_Plugins |
323 | } | 323 | } |
324 | 324 | ||
325 | /// <summary> | 325 | /// <summary> |
326 | /// Sätter Reporting name | ||
327 | /// </summary> | ||
328 | [DisplayName("Report Name Automator")] | ||
329 | [Description("(C) Copyright 2017 LIGHTS IN LINE AB\r\nSätter automatiskt Reporting Name på requests")] | ||
330 | public class WebTestReportingNameAutomator : WebTestPlugin | ||
331 | { | ||
332 | [DisplayName("Use RegEx with group")] | ||
333 | [Description("Will use the Set To Name as a regular expression with a group and use the matching group result as the Reporting Name. If no match, reporting name will not be set to \"no-match\"")] | ||
334 | [DefaultValue(false)] | ||
335 | public bool useRegGroup { get; set; } | ||
336 | |||
337 | [DisplayName("Run on Dependents")] | ||
338 | [Description("If set to true will run on dependents")] | ||
339 | [DefaultValue(false)] | ||
340 | public bool runOnDependents { get; set; } | ||
341 | |||
342 | [DisplayName("Run on Requests")] | ||
343 | [Description("If set to true will run on requests (default)")] | ||
344 | [DefaultValue(true)] | ||
345 | public bool runOnRequests { get; set; } | ||
346 | |||
347 | [DisplayName("Set to Name")] | ||
348 | [Description("The name to be set or the regular expression to be used. Groups are specified within () like (.+?) would match the shortest possible string")] | ||
349 | [DefaultValue(false)] | ||
350 | public string reportingName { get; set; } | ||
351 | |||
352 | private Regex regex = null; | ||
353 | public override void PostRequest(object sender, PostRequestEventArgs e) | ||
354 | { | ||
355 | if(runOnDependents) | ||
356 | foreach (WebTestRequest r in e.Request.DependentRequests) | ||
357 | { | ||
358 | r.ReportingName = getNameToSet(r.Url); | ||
359 | } | ||
360 | } | ||
361 | |||
362 | public override void PreRequest(object sender, PreRequestEventArgs e) | ||
363 | { | ||
364 | if (runOnRequests) | ||
365 | e.Request.ReportingName = getNameToSet(e.Request.Url); | ||
366 | } | ||
367 | |||
368 | private void createRegExOnce() { | ||
369 | if(regex == null) { | ||
370 | regex = new Regex(reportingName); | ||
371 | } | ||
372 | } | ||
373 | |||
374 | private string getNameToSet(string input) { | ||
375 | string result = "no-match"; | ||
376 | if (useRegGroup == false) | ||
377 | result = reportingName; | ||
378 | else | ||
379 | { | ||
380 | createRegExOnce(); | ||
381 | Match m = regex.Match(input); | ||
382 | if (m.Success && m.Groups.Count > 0) | ||
383 | { | ||
384 | result = m.Groups[0].Value; | ||
385 | } | ||
386 | } | ||
387 | return result; | ||
388 | } | ||
389 | } | ||
390 | |||
391 | /// <summary> | ||
326 | /// Service Manager Plugin | 392 | /// Service Manager Plugin |
327 | /// </summary> | 393 | /// </summary> |
328 | [DisplayName("Service Manager Config")] | 394 | [DisplayName("Service Manager Config")] | ... | ... |
... | @@ -33,5 +33,11 @@ | ... | @@ -33,5 +33,11 @@ |
33 | <RuleParameter Name="PreRequestVal" Value="False" /> | 33 | <RuleParameter Name="PreRequestVal" Value="False" /> |
34 | </RuleParameters> | 34 | </RuleParameters> |
35 | </WebTestPlugin> | 35 | </WebTestPlugin> |
36 | <WebTestPlugin Classname="LIL_VSTT_Plugins.WebTestDependentRegexFilter, LIL_VSTT_Plugins, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null" DisplayName="Dynamisk URL Regex filter" Description="(C) Copyright 2011 LIGHTS IN LINE AB
Filter för att ignorera vissa objekt på websidor så de inte laddas ner automatiskt."> | ||
37 | <RuleParameters> | ||
38 | <RuleParameter Name="FilterString" Value="stat.swedbank.se" /> | ||
39 | <RuleParameter Name="Exclude" Value="True" /> | ||
40 | </RuleParameters> | ||
41 | </WebTestPlugin> | ||
36 | </WebTestPlugins> | 42 | </WebTestPlugins> |
37 | </WebTest> | 43 | </WebTest> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment