Cucumber 6 + deltapike,支持范围内的任何场景吗?

时间:2020-12-21 11:57:07

标签: cucumber cucumber-java cucumber-junit deltaspike

我正在使用 Cucumber JVM + deltaspike(焊接)集成。

提供以下资源提供程序类:

@ApplicationScoped
public class CucumberTestProvider {

    Map<String, User> users;

    @PostConstruct
    void init() {
        this.users = new HashMap<>();
    }
    
    @UserInfo
    @Produces
    public final User produceUser(InjectionPoint injectionPoint) {
        final UserInfo annotation = injectionPoint.getAnnotated().getAnnotation(UserInfo.class);
        return users.getOrDefault(annotation.value(), createUser(injectionPoint));
    }
    
    ..below create user method

}

和这样配置的cart.feature:

@carts
Feature: operate with customer cart
  Verify all cart operations

  Scenario: Put 1 article into cart
    Given I have an empty cart
    When I put 1 article(s) into cart
    Then I verify all items are on cart
      
  Scenario: Put 2 articles into cart
    Given I have an empty cart
    When I put 2 article(s) into cart
    Then I verify all items are on cart

我希望在第二个场景中已经创建了用户(将 2 篇文章放入购物车)。 不幸的是,对于每个场景,所有应用程序范围的 bean 看起来都在初始状态被重置,因此 users 字段从空映射重新启动。

有没有建议至少为每个场景保持状态?

0 个答案:

没有答案