docs icon indicating copy to clipboard operation
docs copied to clipboard

Add info on naming conventions for CucumberOptions

Open mlvandijk opened this issue 6 years ago • 6 comments
trafficstars

Q&A from Slack:

J Ku [19:17] qq. i noticed that you can configure naming conventions using the @ CucumberOptions annotations. is there any documentation on, or any official convention on the matter? specifically, the naming convention for feature files vs step definitions (Java in my case), as well as things like function and variable naming?

mpkorstanje [19:33] None that have been written down.

  1. Feature files: kebab-case.
  2. Step definition classes: PascalCase.
  3. Step definition methods lowercase_with_underscores.
  4. Feature file location. /src/main/resources/com/example/my/app
  5. Step definition locations com.example.my.app
  6. Runner class location: com.example.my.app

This reduces the amount of configuration needed. So you benefit from convention over configuration which is always a nice convention. If you do these things you don't have to configure glue, or features in @CucumberOptions.

mlvandijk avatar Feb 21 '19 06:02 mlvandijk

Location wise, it should go here: https://docs.cucumber.io/cucumber/api/#junit above the examples of how to configure specific things, as you won't have to configure them if you follow conventions. Using a header called "Conventions".

mlvandijk avatar Apr 05 '19 10:04 mlvandijk

@mlvandijk @mpkorstanje Hi, I'm looking at this issue, the 3 latters are fine

4. Feature file location. /src/main/resources/com/example/my/app
5. Step definition locations com.example.my.app
6. Runner class location: com.example.my.app

but the 3 formers are a little bit confusing to me

1. Feature files: kebab-case.
2. Step definition classes: PascalCase.
3. Step definition methods lowercase_with_underscores.

What's the point of these rules? I see no logic regarding this. The only I can find is filtering feature files and glue classes in ResourceScanner, but they all use NULL_FILTER, which accepts all.

@annabaker are you working on this? I'm willing to help.

ltpquang avatar Oct 20 '20 12:10 ltpquang

What's the point of these rules?

Consistency between all examples in the documentation and making it easier to spot "wrong" things when people use Cucumber.

  1. Is the Java standard for class names.
  2. Is is the default used in generated step definitions.
  3. Had to pick something.

mpkorstanje avatar Oct 20 '20 13:10 mpkorstanje

  1. Feature file location. /src/main/resources/com/example/my/app

This is the location. It can be also be referenced as glue = "classpath:com/example/my/app"

mpkorstanje avatar Oct 20 '20 13:10 mpkorstanje

@mpkorstanje so as my understanding, this issue's goal is to document: how to use CucumberOptions (not how current framework behaves), is that right?

ltpquang avatar Oct 20 '20 14:10 ltpquang

The goal is to provide a recommendation in the form of a set of naming conventions to use when organizing a Cucumber java project. These conventions can be documented along side @CucumberOptions but if you think they might be better of elsewhere that is possible too.

mpkorstanje avatar Oct 20 '20 15:10 mpkorstanje