cucumber / cucumber-jvm

Cucumber for the JVM
https://cucumber.io
MIT License
2.7k stars 2.02k forks source link

Possibility of setting up mock data just once for all the feature files #2915

Open divyapuramshetty opened 1 month ago

divyapuramshetty commented 1 month ago

šŸ¤” What's the problem you're trying to solve?

Is it possible to setup mock data just once before all the features run ?

āœØ What's your proposed solution?

May be a global hook that could just run once for all the features and not before every feature file.

ā› Have you considered any alternatives or workarounds?

yes, leveraging Java at the moment to do this.

šŸ“š Any additional context?

No response

davidjgoss commented 1 month ago

Can you specify the tool and version you are using please? This issue is raised under cucumber-js but you mentioned Java, and maybe hinted there is a framework in the mix too?

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 3 weeks with no activity. Remove the stale label or comment or this will be closed in another 5 days.

divyapuramshetty commented 1 month ago

Hi, sorry for the delayed response. We are leveraging cucumber for end to end testing (using webservice call's to validate the responses). Cucumber version 7.18.0, Spring boot 2.5.14 We need to setup test data in the environments before the cucumber tests start running (like table's and lookups that drive the logic and validation). Currently with webhooks and tags ex: @BeforeAll- the test data will run either for every scenario, step or feature. If I have 5 features a global hook will run 5 times. I was trying to find a solution that could just set up the test data for all the features only once and not for every feature. Please let me know if you need more info.

davidjgoss commented 1 month ago

Iā€™m going to move this issue to the correct repository so we can respond better there.

mpkorstanje commented 1 month ago

Cucumber has @BeforeAll and @AfterAll hooks since v7. You could use those.

https://github.com/cucumber/cucumber-jvm/tree/main/cucumber-java#beforeall--afterall