Unable to call method annotated with @Before hook in Cucumber JVM

42 views
Skip to first unread message

Abhishek Gedam

unread,
Jun 25, 2016, 7:28:39 AM6/25/16
to Cukes
I am using @Before hook to get the Scenario in the Step. The code snippet is as below.

import cucumber.api.java.Before;

private Scenario scenario    
@Before
      public void beforeScenario(Scenario scenario){
            this.scenario = scenario;

    }
Now when the step file is executed, I am getting following error

Cucumber.runtime.CucumberException: Error creating bean with name 'com.steps.TestSteps': Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
        at cucumber.runtime.java.spring.SpringFactory.getInstance(SpringFactory.java:182)
        at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:60)
        at cucumber.runtime.Runtime.runHookIfTagsMatch(Runtime.java:223)
        at cucumber.runtime.Runtime.runHooks(Runtime.java:211)
        at cucumber.runtime.Runtime.runBeforeHooks(Runtime.java:201)
        at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:40)
        at cucumber.runtime.model.CucumberFeature.run(CucumberFeature.java:165)
        at cucumber.runtime.Runtime.run(Runtime.java:121)
        at cucumber.api.cli.Main.run(Main.java:36)
        at cucumber.api.cli.Main.main(Main.java:18)
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.steps.TestSteps': Instantiation of bean failed; nested exception is java.lang.ExceptionInInitializerError
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1101)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
        at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:342)
        at cucumber.runtime.java.spring.GlueCodeScope.get(GlueCodeScope.java:15)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:217)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:350)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:331)
        at cucumber.runtime.java.spring.SpringFactory.getInstance(SpringFactory.java:180)
        ... 9 more
       
       
I am using cucumber jvm 1.2.2. Can any one help out here?
Reply all
Reply to author
Forward
0 new messages