paul
paul

Reputation: 4487

Create step definitions with underscore in IntelliJ

I was going through this post IntelliJ - Cucumber step definition case

But I don't see cucumber config in IntelliJ community edition version 11.0.8.

enter image description here

I already have Cucumber Java plugin installed.

enter image description here

Restarted IntelliJ after adding --snippets underscore but it is still giving camelcase.

enter image description here

So how can I get underscore instead of camelcase?

Upvotes: 1

Views: 695

Answers (1)

user1207289
user1207289

Reputation: 3273

To get underscore instead of camel case add the below properties in your junit-platform.properties . If this file does not exist , you can create and place it in src/test/resources . Junit5 will detect it automatically and run based on configs provided in that file. For junit5 , we should be using this in pom cucumber-junit-platform-engine

cucumber.plugin = summary
cucumber.snippet-type=underscore
cucumber.execution.dry-run= true

For a scenario like this in feature file

Given I log this <TestTest>

When you build project in intellij , cucumber will generate this on console. You can copy this in stepdefs

@Given("I log this {string}")
public void i_log_this(String string) {
    // Write code here that turns the phrase above into concrete actions
    throw new io.cucumber.java.PendingException();
}

If you are using junit 4 you have to use corresponding options in your

@RunWith(Cucumber.class)

You can find related information on this cucumber docs

Upvotes: 1

Related Questions