Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating Scenario hooks examples to be more like a SSCCE #424

Open
Brice1994 opened this issue Dec 2, 2019 · 5 comments
Open

Updating Scenario hooks examples to be more like a SSCCE #424

Brice1994 opened this issue Dec 2, 2019 · 5 comments
Labels
📖 documentation Improvements or additions to documentation ⚡ enhancement Request for new functionality

Comments

@Brice1994
Copy link

SSCCE

The examples given in the API documentation are a bit too minimal, and they had me digging around for examples elsewhere, i.e. in the Scenario hooks page:

Before
Before hooks run before the first step of each scenario.

Annotated method style:

@Before
public void doSomethingBefore() {
}

Lambda style:

Before(() -> {
});`

These are the examples given but the actual implementation requires a bit more, at least in the lambda case:

import io.cucumber.java8.En;
public class HooksExample implements En{
    public HooksExample() {
        Before(() -> {
            System.out.println("In before hook.");
        });
    }
}

It doesn't mention anywhere on the page about implementing "En", or that a class constructor is needed for a working example. I would make a change request, but I am not sure on the styling, should there be a full example in each case? or just one at the top.

Thanks for reading.

@mlvandijk mlvandijk added ⚡ enhancement Request for new functionality 📖 documentation Improvements or additions to documentation labels Dec 29, 2019
@mlvandijk
Copy link
Member

Hi @Brice1994 - thanks for pointing that out. I would love better examples, if you are willing to start a PR for that. I'd prefer the examples to be consistent, so if you don't mind updating all the examples in this section, I'd be very grateful!

@Brice1994
Copy link
Author

Brice1994 commented Dec 31, 2019

Ok, just a couple questions before I move on with it,

  1. I see the hooks can be done in multiple languages, I am assuming I should just write the examples in English, but should I add any additional notes about other languages?

  2. After digging I have found you can implement the Before, After, etc. in a class constructor or just a method, should I include both? or will 1 be fine?

@mlvandijk
Copy link
Member

Ad 1. Yes, please examples in English. A small note about other languages would be nice, if it doesn't create any confusion (i.e. it might lead to having to explain how to use cucumber with other languages, which may or may not be a separate PR. Idk)

@mlvandijk
Copy link
Member

Ad 2. Not sure what we have now, or whether we recommend one over the other. @mpkorstanje might know?

@mpkorstanje
Copy link
Contributor

mpkorstanje commented Jan 24, 2020

The annotated method has my preference. To avoid making the java doc overly complex I'd focus on cucumber-java and so I'd leave out the lambdas all together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📖 documentation Improvements or additions to documentation ⚡ enhancement Request for new functionality
Projects
None yet
Development

No branches or pull requests

3 participants