cancel
Showing results for 
Search instead for 
Did you mean: 

How to call a step in Step definition in TestComplete

Contributor

How to call a step in Step definition in TestComplete

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.

11 REPLIES 11
Highlighted
Community Leader

Re: How to call a step in Step definition in TestComplete

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?

Contributor

Re: How to call a step in Step definition in TestComplete

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");

}  

Community Manager

Re: How to call a step in Step definition in TestComplete

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?

 

 

---------
Tanya Gorbunova
SmartBear Community Manager

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!
Community Hero

Re: How to call a step in Step definition in TestComplete

Hi,

 

you used to work with BDD in TestComplete.

Actually, no, I am not. Smiley Happy

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.)

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Contributor

Re: How to call a step in Step definition in TestComplete

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?

Contributor

Re: How to call a step in Step definition 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.

Community Hero

Re: How to call a step in Step definition in TestComplete

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.

 

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
Contributor

Re: How to call a step in Step definition in TestComplete

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

Contributor

Re: How to call a step in Step definition in TestComplete

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