Escape characters in Cucumber step definition

19,117

You could do this,

Then the /'The 7 Things $channel' label is displayed/

Corresponding Step def would be,

 @Then("^the /'The 7 Things \\$channel' label is displayed/$")
   public void the_The_Things_$channel_label_is_displayed() throws Throwable {
      System.out.println("hello");
   }
Share:
19,117
nabster
Author by

nabster

When I am not building things with computers, I am building things with hands (aspiring DIY-er).

Updated on June 05, 2022

Comments

  • nabster
    nabster almost 2 years

    I have following steps that I am using for Cucumber-jvm. How do I escape certain characters in my step definitions?

    When user verifies if ABC widget exists
    Then the 'The 7 Things $channel' label is displayed
    

    In this case I need to escape 7 and $ as a regular string.