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

问题描述

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

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

@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 字段从空映射重新启动。

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

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)