当前位置: 首页 > 知识库问答 >
问题:

在原木上看不到cucumber片段

孟和怡
2023-03-14

我刚刚启动了一个Spring Boot项目版本2.1.6(使用启动器:spring boot starter web,spring BootStarter测试)

我正在尝试在版本4.7.1中使用cucumber for java,并带有以下maven依赖项:cucumber-Spring、cucumber-jUnit、cucumber-java8。

当我启动验收测试时,我看到日志上何时未定义步骤。但不显示任何代码段

所有验收测试

@RunWith(Cucumber.class)
@CucumberOptions(plugin = {"pretty", "html:FeaturesReport"},
        features = {"src/test/resources/features"},
        snippets = CucumberOptions.SnippetType.UNDERSCORE)
public class AllAcceptanceTests {
}

我的情景

  Scenario: Creation from initialisation
    Given name "Jean"
    Given gender "Male"
    Given picture "picture.png"
    Given account identifier 1
    When try to create the profile with these parameters
    Then the profile id = 1 , name = "Jean" , gender = "Male" and picture = "picture.png" is saved

JUnit日志

  Scenario: Creation from initialisation                                                            # src/test/resources/features/create-profile.feature:9
    Given name "Jean"                                                                                       # ProfileSteps.java:23
    Given gender "Male"                                                                                     # ProfileSteps.java:27
    Given picture "picture.png"                                                                             # ProfileSteps.java:31
    Given account identifier 1                                                                              # null
    When try to create the profile with these parameters                                                    # ProfileSteps.java:37
    Then the profile id = 1 , name = "Jean" , gender = "Male" and picture = "picture.png" is saved # ProfileSteps.java:46

io.cucumber.junit.UndefinedThrowable: The step "existing account in nisfee-account :" is undefined

我使用的是所有Spring启动默认配置。我是否忘记了一些东西,因为我的日志中有这样的东西:

You can implement missing steps with the snippets below:

@Given("^today is Sunday$")
public void today_is_Sunday() {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

共有1个答案

吴俊晤
2023-03-14

如果您运行的是JUnit而不是CLI或IDEA,则必须显式添加<code>摘要</code>插件。

@CucumberOptions(plugin = {"summary", "pretty", "html:FeaturesReport"},
 类似资料:
  • 这是我的 这是我的文件 这是我的依赖项

  • 我碰到了一些我不明白的事情。 有人知道为什么这不起作用吗? 谢谢你的帮助。

  • 我阅读下面的文章,以了解我建立的ELK环境的日志技术。https://tpodolak.com/blog/tag/kibana/ 我在日志中添加了输入路径 C/日志/*.log。我有测试.log文件,它不为空,它有: 我的日志(C:\监控\logstash\日志\C:\监控\logstash\logs.log):

  • 我目前正在运行mvn测试时收到此日志 我的pom.xml是这样的: 我的IssueTest.java如下所示: 我不知道为什么IssueTest.Java没有被正确读取,尽管我在maven surefire插件的构建配置中添加了它。 请告知。

  • 我试图用junit运行cucumber testRunner,但我得到了“没有发现后端”异常。我发现了类似的exeception解决方案,但它们会得到运行时异常,而我的解决方案与该异常不同。有人能调查一下吗。 我的pom文件中有所有的依赖项,请找到下面的依赖项详细信息

  • 替换中国大陆主流视频网站的 Flash 播放器为 HTML5 播放器 使用 Mac 的同学都可能碰到过在线看视频引起机子风扇狂转、机身发烫等情况,这是因为 Flash 占用了过多系统资源的缘故。 目前主流视频网站(包括但不限于 优酷、土豆、奇艺、搜狐、QQ、56 等)都支持 iOS 设备的在线播放,同时使用非 iOS 设备访问则会使用默认的 Flash 播放器。 这个 Chrome 浏览器的扩展原