开发者

maven with cuke4duke: optionally defining cucumber tags on cmd line

As a test developer using cuke4duke with maven2, I want to be able to optionally select tests by tags on the cmd line. It seems that since maven doesn't have conditionals, the 'optionally' part requires a hack.

The cucumber arg might be e.g. "--tags @firstTag". One way to implement this is to have in pom.xml

<cucumberArgs>
  ...
  <cucumberArg>${tagargs}</cucumberArg>
</cucumberArgs>

Then the cmd line has

 mvn integration-test -Dtagargs="--tags @firstTag"

This works fine when I want to define tags, but when I don't include that -D argument (i.e.开发者_C百科 not selecting by tags), I get

[INFO] No such file or directory - null (Errno::ENOENT)

A workaround is to define ${tagargs} in properties as a duplicate of a cucumber arg I already use:

 <properties>
   <tagargs>--strict</tagargs>
 </properties>

So, worst case is I get "--strict --strict". Is such a hack the best maven is capable of?


I've managed to work around this problem using an ignored negative tag. Note I'm using cuke4duke 0.4.4.

Define a default value for your property that runs all scenarios that are NOT tagged with "ignore" (call it whatever you like).

<properties>
    <tagargs>--tags=~@ignore</tagargs>
</properties>

Maven will use this property when you do not pass in a specific value on the command line. Therefore all of your scenarios will match and execute.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜