How can i call step into another scenario for the Step definition.I know how to do this in Specflow but i do not how the to call the step in other to avoid duplication.Could you please give me example how to do it in Step definition not the feature files.
Solved! Go to Solution.
Hi,
What about this:
[Binding]
public class MySteps: Steps
{
Given("I want to create a sales order") ------------Senario 1 - step definition
public void CreateSalesOrder()
{
__CreateSalesOrder();
}
Given("I open the sales order page") ------------Senario 1 - step definition
public void SalesOrderOpened()
{
__SalesOrderOpened();
}
Given("I click the add new order button") ------------Senario 1 - step definition
public void ClickNewButton()
{
__ClickNewButton();
}
Then("a new sales order is created") ------------Senario 1 - step definition
public void OrderCreated()
{
__OrderCreated();
}
public void __CreateOrder()
{
__CreateSalesOrder();
__SalesOrderOpened();
__ClickNewButton();
__OrderCreated();
}
------For scenario 2's first step which would be calling scenario 1 step definitions
[Given("I have created an order")]
public void CreateOrder()
{
__CreateOrder();
}
Hi,
I am afraid that I don't understand what you mean.
Arey You asking about:
1) TestItem on TestComplete project board?
2) Any BDD framework?
3) Project files and their functions?
4) What programming language are You using in TestComplete?
What is the main goal of Your actions?
Hi,
Could you please see the example for my enquiry.See the example below for the 2 scenarios, the first scenario have step definition but scenario 2 is calling the step definition for scenario 1 in other to fulfil Feature steps:Given I have created an order.How can i achieve this with TestComplete on JScript.
Scenario: 1 I create new sale
Given I want to create a sales order
When I open the sales order page
Then a new sales order is created
"
Scenario: 2 I add another sale
Given I have created an order
When I add a sales order line
Then the order total is updated
The step definitions for Scenario 1 that within the method for the first scenario 2 file step[Given I have created an order] for scenario 2,would be executed .How can i acnhieve in TestComplete?
[Binding]
public class MySteps: Steps
{
[Given("I have created an order")]
public void CreateOrder()
{
Given("I want to create a sales order");
Given("I open the sales order page");
Given("I click the add new order button");
Then("a new sales order is created");
}
Let's see if Alex Karas - our community hero - can help here. @AlexKaras, as far as I remember, you used to work with BDD in TestComplete. Could you please help us with this question?
Hi,
> you used to work with BDD in TestComplete.
Actually, no, I am not. 🙂
Especially after a great webinar by Seb Rose (https://community.smartbear.com/t5/TestComplete-General-Discussions/The-Secrets-of-Successful-Collab...) and the really fruitful follow-up discussion...
However, if I got the initial question right, this is not possible because pure Gherkin does not support tree-like scenarios and/or steps.
Maybe the requested can be obtained with the help of Scenario Preconditions (which are supported by Gherkin if I remember it right) or Keywords functionality provided by Zephyr.
What will work for sure is if tests are properly organized within Test Items tree in the TestComplete's project so that the descendant child uses the result of its parent and predecessors. (Yes, I know that this is not popular point of view but my opinion is that this is correct for unit/integration tests. High level end-to-end functional tests well may use results of actions done by previous tests.)
Is this a limitation to TestComplete? The above example reduces multi-steps in Scenario when the step has a step definition(code behind) already from another scenario.
How should I call steps(code behind for scenario-step) from step definition(code behind for scenario-step) in TestComplete?
Also, this is possible with Specflow and Visual Studio with pure Gherkins. It may possibly on TestComplete but I need someone to help in this matter.
Hi,
Gherkin does not support nested scenarios/steps. This means that you cannot reference another step from some other step.
Step's implementation is a code. Which means that you may (and, probably, should) implements steps as a standalone functions and call these functions from Gherkin. In this case you may have a function that creates initial order and call this function from more than one step.
Thank you for your reply. The example above is the way it works with Specflow(gherkin) and visual studio with the step definition(code implementation for the scenario steps). I do not need to have a dependency function in VS-Specflow, I would be calling the scenario-steps(binding) for the actual calling scenario steps I need to call in a required scenario - step definition(code implementation) to avoid unnecessary multi Ghekins scenario - steps.
I think the behaviour in TestComplete is not the same as Specflow in VS and Cucumber
Could you please see the example again.I have two scenarios and i wanted to run the same steps for scenario 1 in scenario 2, i do not need to design the same step in scenario 2.See the example below.
Scenario: 1 I create new sale
Given I want to create a sales order
When I open the sales order page
Then a new sales order is created
Scenario: 2 I add another sale
Given I have created an order
When I add a sales order line
Then the order total is updated
[Binding]
public class MySteps: Steps
{
Given("I want to create a sales order") ------------Senario 1 - step definition
public void CreateSalesOrder()
{
}
Given("I open the sales order page") ------------Senario 1 - step definition
public void SalesOrderOpened()
{
}
Given("I click the add new order button") ------------Senario 1 - step definition
public void ClickNewButton)
{
}
Then("a new sales order is created") ------------Senario 1 - step definition
public void OrderCreated()
{
}
------For scenario 2's first step which would be calling scenario 1 step definitions
[Given("I have created an order")]
public void CreateOrder()
{
Given("I want to create a sales order") ----Calling --Senario 1 - step definition
Given("I open the sales order page") ----Calling --Senario 1 - step definition
Given("I click the add new order button") ----Calling --Senario 1 - step definition
Then("a new sales order is created") ----Calling --Senario 1 - step definition
}
Subject | Author | Latest Post |
---|---|---|