如何在Cucumber Feature文件中传递含双引号的字符串参数
在Cucumber Feature文件中传递含双引号的字符串参数
当需要在Feature文件的步骤中传递包含双引号的单个字符串参数时(比如你提到的HPC "Big memory" nodes),可以用以下几种方法实现:
使用反斜杠转义内部双引号:在字符串内部的双引号前添加反斜杠,外层仍用双引号包裹,Cucumber会将整个内容识别为单个参数。
And Get the enabled play books of "HPC \"Big memory\" nodes"用单引号包裹整个字符串:如果你的Cucumber版本支持,直接用单引号把包含双引号的字符串括起来,内部双引号无需转义。
And Get the enabled play books of 'HPC "Big memory" nodes'使用文档字符串(Docstring):适合参数内容复杂或多行的场景,用三个连续的双引号(或单引号)包裹参数内容,步骤定义中需对应接收Docstring类型的参数。
And Get the enabled play books of: """ HPC "Big memory" nodes """
内容的提问来源于stack exchange,提问作者Nagaraju
相关产品推荐
相关产品推荐

