mmar
mmar

Reputation: 2030

Any cucumber Before and After hook at a feature level

i have gone through many help, but all are about explaining on scenario level. Is there any Before and After hook at feature level for cucumber JVM.? This page cucumber Hook tells about ruby language, but can i get help for java?

Upvotes: 7

Views: 16843

Answers (3)

Kyle Willkomm
Kyle Willkomm

Reputation: 320

This worked for me in Java Cucumber. What is not totally clear in the Cucumber documentation is that you can Tag a Feature; and that will tag all Scenarios in the Feature. This allows you to use the Tag Expression on the After and Before tags to make them run only for the Scenarios within a particular Feature. ex.

@UserServiceEventSubmissionARTSClaimInquiryHooks
Feature: Service Event Submission - ARTS Robot - Claim Inquiry
  Scenario: Temporary scenario for a Claim Inquiry
  ...

@After("@UserServiceEventSubmissionARTSClaimInquiryHooks")
public void afterScenarioDocumentation(Scenario scenario){
    if (callDetailProducerSubmission != null) {
       ...

Upvotes: 0

RKM
RKM

Reputation: 27

Cucumber does not support hooks on feature levels like specflow having @BeforeFeature and @AfterFeature tags. This is open issue https://github.com/cucumber/cucumber-jvm/issues/515

Upvotes: 0

Paul Harris
Paul Harris

Reputation: 5819

The following contains many of the avialable hooks: http://zsoltfabok.com/blog/2012/09/cucumber-jvm-hooks/

Similar to junit it appears there is an annotationo for @Before and @After

Upvotes: 0

Related Questions