【问题标题】:How can I use @beforestory annotation in my tests如何在测试中使用 @beforestory 注释
【发布时间】:2014-09-11 02:34:37
【问题描述】:

我正在使用 Jbehave 自动化我的测试。

我使用了某些注释,现在我想在执行故事之前进行某些设置。

例如

如果我有 5 个用户故事,那么我应该有 5 个 @before 故事注释来执行不同的任务。

谁能指导我如何做到这一点?

我通过 Google 搜索但没有得到正确的解决方案。

记住这是关于@BeforeStory 而不是@BeforeStories。

提前致谢

彻坦!

【问题讨论】:

    标签: jbehave


    【解决方案1】:

    使用 @BeforeStory 注释无法完成,因为使用此注释注释的方法在每个故事之前执行 - 对于所有已执行的故事。

    但是您可以在您的故事中使用lifecycle before 步骤,请查看this 示例:

    A story is a collection of scenarios
    
    Narrative:
    In order to communicate effectively to the business some functionality
    As a development team
    I want to use Behaviour-Driven Development
    
    
    Lifecycle:
    Before:
    Given a step that is executed before each scenario
    After:
    Outcome: ANY   
    Given a step that is executed after each scenario regardless of outcome
    Outcome: SUCCESS
    Given a step that is executed after each successful scenario
    Outcome: FAILURE
    Given a step that is executed after each failed scenario
    
    Scenario:  A scenario is a collection of executable steps of different type
    
    Given step represents a precondition to an event
    When step represents the occurrence of the event
    Then step represents the outcome of the event
    



    注意Lifecycle: Before:关键字:

    Lifecycle:
    Before:
    Given a step that is executed before each scenario
    

    这些关键字旁边的given 步骤将在本故事中的每个场景之前执行 - 但仅适用于本故事中的场景,而不适用于其他故事。

    【讨论】:

    • 非常感谢,我会尝试一下,如果有任何问题,请联系您
    猜你喜欢
    • 2013-09-22
    • 1970-01-01
    • 2020-02-14
    • 1970-01-01
    • 1970-01-01
    • 2021-11-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多