3

I am trying to implement an automated evidence capture system for each cucumber scenario that is executed. As part of that I need to use the first scenario @tag as part of the evidence folder name.

However, I have found that the getSourceTagNames() method on a cucumber scenario returns the list in a random order, compared to the order in which the tags were written. So simply calling scenario.getSourceTagNames().get(0) will not consistently give me the tag I need.

e.g Scenario: Example @tagINeed @secondTag @thirdTag

getSourceTagNames() may return {@thirdTag, @tagINeed, @secondTag}

Is there a way to ensure the list returned is in the same order as the order in which it was written?

4

1 回答 1

1

您正在寻找的可以使用带有 qaf 的小黄瓜来实现,您将能够按照它们定义的顺序访问标签,例如:

@tagINeed @secondTag @thirdTag
Scenario: Example 

Java代码:

scenario.getGroups()[0];//will return "@tagINeed"

如果您将使用BDD2 语法而不是小黄瓜,则可以使用带有场景的元数据。例如:

@TestID:ABC-123
@Evidence:tagINeed @firstTag @secondTag
Scenario: Example 

Java代码:

scenario.getMetaData().get("Evidence");//will return "tagINeed"
scenario.getGroups()[0];//will return "firstTag"
于 2019-03-01T23:01:02.883 回答