Forum Discussion

funmay's avatar
funmay
Contributor
6 years ago

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.

  • 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();

     

  • Wamboo's avatar
    Wamboo
    Community Hero

    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?

    • funmay's avatar
      funmay
      Contributor

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

      }  

      • TanyaYatskovska's avatar
        TanyaYatskovska
        SmartBear Alumni (Retired)

        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?