如何在Cucumber步骤定义中转义特殊字符? [英] How to escape special characters in Cucumber step definitions?

查看:607
本文介绍了如何在Cucumber步骤定义中转义特殊字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下步骤,我正在使用cucumber-jvm(黄瓜的java变体)。我可以在步骤定义中转义特殊字符吗?

I have following steps that I am using for cucumber-jvm (a java variant of cucumber). Can I escape special characters in my step definitions?

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

在这种情况下,我需要将7和$作为常规字符串

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

推荐答案

您可以这样做:

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

def会是,

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

这篇关于如何在Cucumber步骤定义中转义特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆