简体   繁体   中英

How to make the java cucumber simplest example fully work in Eclipse?

I'm new to cucumber and after trying various not fully working tutorials, I try to make this example work: https://github.com/cucumber/cucumber-java-skeleton

Here is the plugin i'm using: 在此处输入图像描述

My version of Eclipse (wrapped into STS 4.17.1):

在此处输入图像描述

To import it, I do "Import Existing maven project" on the maven project: 在此处输入图像描述 在此处输入图像描述

What works: After completing the 2 missing steps, when I run the.feature through eclipse cucumber plugin (Run as "Cucumber feature") or through "mvn test", I get:

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

What doesn't work (related to the eclipse cucumber plugin?), 3. and 4. are the main issues:

  1. In Eclipse, output starts with:

    janv. 31, 2023 3:23:38 PM cucumber.api.cli.Main run WARNING: You are using deprecated Main class. Please use io.cucumber.core.cli.Main

This may or may not be important for the following not working items.

1b. "growl:" is displayed BEFORE the step where it is implemented :

    @Then("my belly should growl")
    public void my_belly_should_growl() {
        System.out.println("growl !");
    } 
  1. In Eclipse, I'm getting this message despite all the "quiet" properties positionned in the right.properties files:
    ┌───────────────────────────────────────────────────────────────────────────────────┐
    │ 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. I'm not getting any generated cucumber report in maven "target" directory
  2. If I do "Run as JUnit" in Eclipse on this project to get a visual report in the JUnit tab, I get:
    org.junit.platform.suite.engine.NoTestsDiscoveredException: Suite [io.cucumber.skeleton.RunCucumberTest] did not discover any tests

I'd like to see the cucumber tests like this in Eclipse: 在此处输入图像描述

Please help me make Cucumber work in Eclipse or at least generate an html cucumber report in target.

what I can say you regarding your q:

  1. seems like the answer is here: github issue thread

1b. I do not see in the repo you provided this example, so it is hard to say what is wrong here, I am assuming you have an extra repo with updated skeleton, so you may provide more details

  1. have you checked this thread? quite props

  2. What I know about Cucumber reports, you need in your Runner class, you set a path to your json cucumber report:

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

More examples are here: cucumber reports

  1. Check if your setup is correct, I think the best place for it is: Running Cucumber Tests

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM