Filter on tag of scenario outline example
Hello guys,
A (hopefully) quick question for you:
I am trying to use the BDDHooks file to print the time needed for running 1 scenario into an excel file.
This is all working perfectly but the problem is I am using a couple of scenario outlines with different examples and
I split the examples into different blocks to all give them their own tag (@smoke and @happyUnhappy eg). Now my goal is to only print the timing of the one example with the tag '@smoke' but I cannot seem to find a way to filter by example tag.
I know there's this page https://support.smartbear.com/testcomplete/docs/bdd/tags.html which explains how to get all tags of a certain feature or scenario but there's none to get the tags from a scenario outline. I only seem to be able to retrieve the tags for the entire outline and not for 1 example.
eg; I only need to save the time for the example with @smoke on top:
@smoke
Examples:
|a|b|c|
|1|2|3|
@happyUnhappe
Examples:
|d|e|f|
|4|5|6|
I hope you guys understand and you can help me in my search 🙂
Thanks!
Ah, I see. This is going to be a bit tricky in any automation framework since the tag isn't necessarily part of the input data for whatever routine is executed. There is a way to capture that in TestComplete however, using the Project.TestItems.Current object.
Below is a way of evaluating a tag for a predetermined value and setting a temporary project variable of Boolean type, based on the tag itself;
Given("some precondition", function (){ Log.Message(Project.TestItems.Current.ElementToBeRun.Caption); Log.Message("Store The Timings? " + aqString.StrMatches("examples2", Project.TestItems.Current.ElementToBeRun.Caption)); Project.Variables.Exporttimings = aqString.StrMatches("examples2", Project.TestItems.Current.ElementToBeRun.Caption); Log.Message("Executing First Step"); /* * Calls to Project.KeywordTests tests or Script functions go here */ });
( I used JavaScript, but the concept would be the same for any of the supported languages in TestComplete ).
If you're using an After Scenario Hook that can evaluate the Project Variable, then you can perform the timing export just for that particular tag;AfterScenario(function (scenario){ // Perform some action after executing a scenario, for example: Log.Message("The " + scenario.Name + " scenario has been executed"); Log.Message("Return The Timings? " + Project.Variables.Exporttimings ); if (Project.Variables.ExportTimings){ exportTimings(Project.Variables.TimingData ); } })
This results in a Test Log that looks like this;
and if we use the other tag, our test log looks like this;
Do you think that may handle your requirements?