How to get child test case pathname in Katalon Studio - katalon-studio

If you're reading this question, chances are that you already know how to get pathname of a test case in Katalon Studio :
RunConfiguration.getExecutionSourceId()
However, that doesn't seem to work on child test cases. For example, in my case, I have some child test case, whose path is Test Cases/New Zoho/Member Lead/New Zoho - Member Lead, being called from parent test case Test Cases/New Zoho/New Zoho - 02 Create Practice. It is in a benchmark handler class, that create the benchmark file if it doesn't already exist, using the test case pathname.
The New Zoho - Member Lead test case has some code that ends up using RunConfiguration.getExecutionSourceId(). When I put debug breakpoint at that line, and run it, I see Test Cases/New Zoho/New Zoho - 02 Create Practice. and not the name of the child test case. It ends up creating New Zoho/New Zoho - 02 Create Practice.xlsx instead of appending to the already-existing New Zoho/Member Lead/New Zoho - Member Lead.xlsx in the benchmark data folder...
How do I get the child test case name here instead?

It looks like you can do something like this:
RunConfiguration.getExecutionProperties().get("current_testcase")
to get the id of the current test case context, even if that test case is a child test case...

Related

Robot Framework : How to add documentation tag for test written in BDD + DD style

Following is my test is written in Robot Framework. It uses the BDD+data-driven approach. It runs perfectly fine. Bue how to add [Documentation] tag for each test. I want that in the report.html, for each test case, documentation should be displayed. How to achieve it?
Settings
Resource …/…/…/resources/high-level-api.robot
Library Collections
Test Template this is my test
Test Cases
TC1 ${data1} ${data2}
TC2 ${data3} ${data4}
TC3 ${data5} ${data6}
Keywords
this is my test
[Arguments] ${valid_data1} ${valid_data2}
When perform step1 ${valid_data1}
And step2 ${valid_data1}
Then I should get ${valid_data2}
Use the [Documentation] setting from user guide.
It should look something like this:
***Settings***
Test Template Log Value
*** Test Cases *** VALUE
Example dummy
[Documentation] first example
Example 2 Value
[Documentation] second example
*** Keywords ***
Log Value
[Arguments] ${value}
Log ${value}

Bdd Cucumber issues

I have newly started working on BDD Cucumber. I am using scala for writing test cases. I am trying to use Scenario Outline and passing parameters in step definitions. My code is as follows.
Scenario Outline: Data is parsed and persisted
Given Portal is running
When A data of <type> is received
Then The data of <type> with <Id> should be parsed and persisted
Examples:
| type | Id |
| Personal | 1 |
|Professional | 2 |
Now in my when condition I am trying to get these parameters as follows
When("""^A data of \"([^\"]*)\" is received$""") {
(type: String) =>
//My code
}
Now on running my code I am getting following error everytime.
io.cucumber.junit.UndefinedStepException: The step "A data of Personal is received" is undefined. You can implement it using the snippet(s) below:
When("""A data of Personal is received""") { () =>
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.scala.PendingException()
}
Though I have my code in when. Also If I don't use Scenario Outline then it works fine but I want to use Scenario Outline for my code.
I am using tags in my feature file to run my test cases. When I run my test cases with command sbt test #tag1, test cases executes fine but when all test cases are finished running on cmd I am getting following error:
[error] Expected ';'
[error] #tag1
I tried putting ";" after tag but still getting same error
What is this issue and how I can resolve it?
I have 4-5 feature files in my application. That means 4-5 tags. As of now the test case which I want to run I give path of feature file and "glue" it with step deinition in my Runner Class. How I can provide all the tags in my Runner class so that my application runs all the test cases one by one when started?
You are missing the double quotes around <type>:
When A data of "<type>" is received
Just some general advice.
When cuking keep things as simple as possible, focus on clarity and simplicity, do not worry about repetition.
Your task would be much simpler if you wrote 2 simple scenarios
Scenario: Personal data
Given Portal is running
When personal data is received
Then personal data should be persisted
Scenario: Professional data
...
Secondly don't use tags to run your features, you don't need tags yet.
You can cuke much more effectively if you avoid scenario outlines, regex's, tags, transforms etc. etc.. The main power in Cucumber is using natural language to express yourself clearly. Focus on that and keep it simple ...

'Automated' option not shown in 'Automation Status' dropdown in Testcase work Item in Azure Devops

In Azure DevOps documentation : https://learn.microsoft.com/en-us/azure/devops/boards/queries/build-test-integration?view=azure-devops
It mentions that :
Field nameDescriptionWork item typeAutomation Status1The status of a test case. You can specify the following values:
Automated
Not Automated
Planned
I am unable to see the Automated Option in the dropdown there are only 2 options available in the dropdown - 'Not Automated' and Planned. Can you please let me know when do you intend to fix this problem ?
The Automated value for Automation Status field is auto set when the test case work item is associated to a test case method. It seems your Test case work item is not associated to test case.
If the Test case work item is not associated. You will only get 'Not Automated' and 'Planned' options in the Automation Status field.
Check document Associate automated tests with test cases to associate your test cases.
When the Test case work item is associated to a test case. You can see the associated test case in the Associated Automation tab. See below:

In MTM Can we create new test case based on the existing test case (copy old test case and modify to create new)

is there any way possible to create new test case based on the existing test case like i want to just update one step and rest of the thing i want to copy from old test case.
Is it possible in Microsoft Test Manager (MTM)
Got the Solution, its very easy..
Just right click on the existing test case and select "Copy and add to suite" it will create new page, modify the test case and add it.
http://msdn.microsoft.com/en-us/library/hh543843.aspx

When running multiple tags with NUnit Console Runner and SpecFlow I get incorrect results

This is a follow up to my earlier questions on setting up tags: Can I use tags in SpecFlow to determine the right environment to use? and setting up variables from those tags: How to set up a URL variable to be used in NUnit/SpecFlow framework
I've set up some variables to aid in populating my NUnit Tests, but I find that when the NUnit runner finds the test that fits the first tag the test runs it with the settings of the second tag. Since the tags are important to me to not only know what test to run, but what variables to use, this is causing me problems.
So if I have the following tags:
#first
#first #second
#second
If I run #second everything is fine. If I run #first I get any scenario that has only #first fine, but when it comes to scenarios where I have both #first #second the scenario is run, because #first is there, however, it uses the parameters for #second. Since I am running the DLL through the NUnit-Console and the Tests are written through SpecFlow I am not sure where the issue may lie.
Does anyone have advice on setting up tests to run like this?
You've not been very specific, but it sounds like you have a feature file like this:
#first
Scenario: A - Something Specific happens under the first settings
Given ...etc...
#second
Scenario: B - Something Specific happens under the second settings
Given ...etc...
#first #second
Scenario: C - Something general happens under the first and second settings
Given ...etc...
It looks like you are selecting tests to run in NUnit by running all the tests in the "first" category.
If you set up event definitions like this:
[BeforeFeature("first")]
public static string FirstSettings()
{ ... }
[BeforeFeature("second")]
public static string SecondSettings()
{ ... }
If you execute scenario C then FirstSettings() and SecondSettings() will be executed before it. This is regardless of whether you used the #second category to select the test to run under NUnit.
This is almost certainly the reason that you are seeing the second settings applied to your test with both tags - I expect the second settings overwrite the first ones, right?
My only advice for setting up tests like this, is that binding events and so on to specific tags can be useful but should be used as little as possible. Instead make your individual step definitions reusable, and set up your test environment, where possible, with Given steps.