将 cucumber-jvm 从版本 4 升级到版本 6 时是否需要额外的上下文配置? [英] Is additional context configuration required when upgrading cucumber-jvm from version 4 to version 6?

查看:23
本文介绍了将 cucumber-jvm 从版本 4 升级到版本 6 时是否需要额外的上下文配置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 cucumber-jvm 在 Kotlin 中执行一些功能测试.

我有标准的空跑步者课程:

@RunWith(Cucumber::class)@CucumberOptions(特征=[foo],胶水=[条],插件=[baz],严格=真,单色=真)类 随便

实际的步骤是在另一个类中使用@ContextConfiguration springframework 注解定义的.此类还使用其他弹簧功能,如@Autowire 或@Qualifier

@ContextConfiguration(locations=["x/y/z/config.xml"])我的班级{...@前...@Given(一些功能文件的东西")...//等等}

这一切在黄瓜 4.2.0 版中都可以正常工作,但是升级到 6.3.0 版会出现问题.在更新导入以匹配新的黄瓜项目布局后,测试现在失败并出现以下错误:

<块引用>

io.cucumber.core.backend.CucumberBackendException: 请用一些上下文配置注释胶水类.

它提供了其含义的示例...

<块引用>

例如:

 @CucumberContextConfiguration@SpringBootTest(classes = TestConfig.class)公共类 CucumberSpringConfiguration {}

<块引用>

或者:

 @CucumberContextConfiguration@ContextConfiguration( ... )公共类 CucumberSpringConfiguration {}

它似乎告诉我我可以将 @CucumberContextConfiguration 添加到 MyClass.

但是为什么呢?

我明白@CucumberContextConfiguration 的意思,它解释得很好here 但是为什么我现在需要版本 6,而版本 4 没有它就可以正常运行?我看不到任何已弃用并被此取代的功能.

任何帮助将不胜感激:)

解决方案

https://github.com/cucumber/cucumber-jvm/pull/1959 删除了上下文配置自动发现.作者得出的结论是,它隐藏了用户错误,删除它可以提供更多的清晰度并降低复杂性.它还列出了用于应用上下文配置自动发现的场景.

注意是在https://github.com/cucumber/cucumber之后引入的-jvm/pull/1911,就是你提到的.

I am using cucumber-jvm to perform some functional tests in Kotlin.

I have the standard empty runner class:

@RunWith(Cucumber::class)
@CucumberOptions(features=[foo],
    glue=[bar],
    plugin=[baz],
    strict=true,
    monochrome=true)
class Whatever

The actual steps are defined in another class with the @ContextConfiguration springframework annotation. This class also uses other spring features like @Autowire or @Qualifier

@ContextConfiguration(locations=["x/y/z/config.xml"])
class MyClass {
    ...
    @Before
    ...

    @Given("some feature file stuff")
    ...

    // etc
}

This all work fine in cucumber version 4.2.0, however upgrading to version 6.3.0 breaks things. After updating the imports to match the new cucumber project layout the tests now fail with this error:

io.cucumber.core.backend.CucumberBackendException: Please annotate a glue class with some context configuration.

It provides examples of what it means...

For example:

    @CucumberContextConfiguration
    @SpringBootTest(classes = TestConfig.class)
    public class CucumberSpringConfiguration {}

Or:

    @CucumberContextConfiguration
    @ContextConfiguration( ... )
    public class CucumberSpringConfiguration {}

It looks like it's telling me I can just add @CucumberContextConfiguration to MyClass.

But why?

I get the point of @CucumberContextConfiguration, it's explained well here but why do I need it now with version 6 when version 4 got on fine without it? I can't see any feature that was deprecated and replaced by this.

Any help would be appreciated :)

解决方案

https://github.com/cucumber/cucumber-jvm/pull/1959 removed the context configuration auto-discovery. The author concluded that it hid user errors and removing it would provide more clarity and reduce complexity. It also listed the scenarios where the context configuration auto-discovery used to apply.

Note that it was introduced after https://github.com/cucumber/cucumber-jvm/pull/1911, which you had mentioned.

这篇关于将 cucumber-jvm 从版本 4 升级到版本 6 时是否需要额外的上下文配置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆