如何使java cucumber最简单的例子在Eclipse中完全工作?

ruarlubt  于 2023-02-04  发布在  Eclipse
关注(0)|答案(1)|浏览(155)

我是 cucumber 新手,在尝试了各种不完全工作的教程后,我试图使这个例子工作:https://github.com/cucumber/cucumber-java-skeleton
下面是我使用的插件:

我的Eclipse版本( Package 在STS 4.17.1中):

要导入它,我在maven项目上执行"Import Existing maven project":第一节第二节第一节第三节第一节
有效措施:完成2个缺少的步骤后,当我通过eclipse cubber插件(以"Cubumber feature"运行)或通过"mvn test"运行. feature时,我得到:

Scenario: a few cukes               # src/test/resources/io/cucumber/skeleton/belly.feature:3
  Given I have 42 cukes in my belly # io.cucumber.skeleton.StepDefinitions.I_have_cukes_in_my_belly(int)
  When I wait 1 hour                # io.cucumber.skeleton.StepDefinitions.i_wait_hour(java.lang.Integer)
growl !
  Then my belly should growl        # io.cucumber.skeleton.StepDefinitions.my_belly_should_growl()

1 Scenarios (1 passed)
3 Steps (3 passed)
0m1,134s

什么不起作用(与eclipse cumper插件有关?),3.和4.是主要问题:
1.在Eclipse中,输出从以下内容开始:
2023年1月31日下午3:23:38 cucumber . api. cli.主运行警告:您正在使用过时的Main类。请使用io. cubble. core. cli. Main
这对于以下不工作的项目可能重要,也可能不重要。
1b."growl!"显示在执行该步骤之前:

@Then("my belly should growl")
    public void my_belly_should_growl() {
        System.out.println("growl !");
    }

1.在Eclipse中,尽管所有的"quiet"属性都位于正确的. properties文件中,但我还是收到了以下消息:

┌───────────────────────────────────────────────────────────────────────────────────┐
    │ Share your Cucumber Report with your team at https://reports.cucumber.io          │
    │ Activate publishing with one of the following:                                    │
    │                                                                                   │
    │ src/test/resources/cucumber.properties:          cucumber.publish.enabled=true    │
    │ src/test/resources/junit-platform.properties:    cucumber.publish.enabled=true    │
    │ Environment variable:                            CUCUMBER_PUBLISH_ENABLED=true    │
    │ JUnit:                                           @CucumberOptions(publish = true) │
    │                                                                                   │
    │ More information at https://cucumber.io/docs/cucumber/environment-variables/      │
    │                                                                                   │
    │ Disable this message with one of the following:                                   │
    │                                                                                   │
    │ src/test/resources/cucumber.properties:          cucumber.publish.quiet=true      │
    │ src/test/resources/junit-platform.properties:    cucumber.publish.quiet=true      │
    └───────────────────────────────────────────────────────────────────────────────────┘

1.我在maven "target"目录中未获得任何生成的cumblue报告
1.如果我在Eclipse中对此项目执行"Run as JUnit"操作,以在JUnit选项卡中获得可视化报告,则会得到:

org.junit.platform.suite.engine.NoTestsDiscoveredException: Suite [io.cucumber.skeleton.RunCucumberTest] did not discover any tests

我希望在Eclipse中看到这样的 cucumber 测试:

请帮助我使Cucumber在Eclipse中工作,或者至少在Target中生成一个HTML Cucumber报告。

yqkkidmi

yqkkidmi1#

关于你的问题我能说什么
1.似乎答案就在这里github issue thread
1b.我没有在您提供的repo中看到此示例,因此很难说这里有什么问题,我假设您有一个带有更新 backbone 的额外repo,因此您可以提供更多详细信息
1.你检查过这个帖子吗?quite props
1.我所知道的关于Cucumber报告的知识,你需要在你的Runner类中,你设置一个路径到你的json Cucumber报告:

@CucumberOptions(
 features = "src/test/resources/functionalTests",
 glue= {"stepDefinitions"},
 plugin = { "pretty", "json:target/cucumber-reports/Cucumber.json" },
 monochrome = true    )

更多示例如下:cucumber reports
1.检查您的设置是否正确,我认为它的最佳位置是:Running Cucumber Tests

相关问题