GivenStories参数化

时间:2015-06-03 13:11:07

标签: bdd jbehave parameterized user-stories

我对“通过示例参数化的GivenStories”存在问题。

我试图通过以下example

来实现下一个流程

我的实现如下:

Main.story

Meta:

GivenStories: dummy/Precondition.story#{0}

Scenario: main scenario
Given have string <first>
When add string <second>
Then print result

Examples:
|first|second|
|aaaa|bbbb|
|cccc|dddd|
|eeee|rrrr|

Precondition.story

Meta:

Scenario: precondition scenario
Given have number <first>
When add number <second>
Then print result

故事的执行......

Processing system properties {}
Using controls EmbedderControls[batch=false,skip=false,generateViewAfterStories=true,ignoreFailureInStories=false,ignoreFailureInView=false,verboseFailures=false,verboseFiltering=false,storyTimeoutInSecs=300,failOnStoryTimeout=false,threads=1]

(BeforeStories)

Running story dummy/Main.story

(dummy/Main.story)
GivenStories:
dummy/Precondition.story#{0} {}


(dummy/Precondition.story)
Scenario: precondition scenario
Given have number <first> (PENDING)
When add number <second> (NOT PERFORMED)
Then print result (NOT PERFORMED)


Scenario: main scenario
Examples:
Given have string <first>
When add string <second>
Then print result

|first|second|
|aaaa|bbbb|
|cccc|dddd|
|eeee|rrrr|

Example: {first=aaaa, second=bbbb}
Given have string aaaa
When add string bbbb
---->aaaabbbb
Then print result

Example: {first=cccc, second=dddd}
Given have string cccc
When add string dddd
---->ccccdddd
Then print result

Example: {first=eeee, second=rrrr}
Given have string eeee
When add string rrrr
---->eeeerrrr
Then print result

(AfterStories)

通过日志,您可以看到前置条件故事实际上没有被执行。 我在这里做错了什么?

1 个答案:

答案 0 :(得分:0)

简单的解决方案,只是找到&#34; GivenStories&#34;在&#34;场景下:&#34;

Meta:

Scenario: main scenario
GivenStories: dummy/Precondition.story#{1}

Given have string <first>
When add string <second>
Then print result

Examples:
|first|second|
|aaaa|bbbb|
|cccc|dddd|
|eeee|rrrr|