scalacucumberbddcucumber-junit

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.

  1. 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?

  1. 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?

Solution

  • You are missing the double quotes around <type>:

    When A data of "<type>" is received