mauriciotogneri / green-coffee

Green Coffee
MIT License
231 stars 21 forks source link

Sharing steps between tests #13

Closed chris-gunawardena closed 7 years ago

chris-gunawardena commented 7 years ago

We have common steps like "Given I'm logged in" that needs to be shared between tests, what the best way to do this? I already tried extending off a CommonSteps class that extends from GreenCoffeeSteps but it's not inheriting the step definitions.

mauriciotogneri commented 7 years ago

Hi, have a look at this example:

https://github.com/vndly/green-coffee-example/tree/master/app/src/androidTest/java/com/mauriciotogneri/greencoffeeexample/test

The idea is to have one class that handles all the steps related to one screen/unit of functionality/feature, etc. (e.g. https://github.com/vndly/green-coffee-example/blob/master/app/src/androidTest/java/com/mauriciotogneri/greencoffeeexample/test/steps/LoginSteps.java)

Then you use the steps in the class that extends from GreenCoffeeTest (e.g. https://github.com/vndly/green-coffee-example/blob/master/app/src/androidTest/java/com/mauriciotogneri/greencoffeeexample/test/features/LoginFeatureTest.java#L48)

Like that you can include a set of common steps in different features easily.

I hope that solves your problem and let me know otherwise.

chris-gunawardena commented 7 years ago

Thanks Mauricio, didn't realise start() method can take multiple arguments.

mauriciotogneri commented 7 years ago

You are welcome! Let me know if you have some ideas or features to improve the library.