Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to run cucumber features directly through intellij run configuration

I am getting this stack trace when running a very basic feature which just opens a browser, navigates to google.com and search some string.

Exception in thread "main" java.lang.NoClassDefFoundError: 
    org/springframework/transaction/TransactionStatus
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.privateGetPublicMethods(Class.java:2902)
    at java.lang.Class.getMethods(Class.java:1615)
    at cucumber.runtime.java.MethodScanner.scan(MethodScanner.java:40)
    at cucumber.runtime.java.JavaBackend.loadGlue(JavaBackend.java:86)
    at cucumber.runtime.Runtime.<init>(Runtime.java:92)
    at cucumber.runtime.Runtime.<init>(Runtime.java:70)
    at cucumber.runtime.Runtime.<init>(Runtime.java:66)
    at cucumber.api.cli.Main.run(Main.java:35)
    at cucumber.api.cli.Main.main(Main.java:18)
Caused by: java.lang.ClassNotFoundException: 
    org.springframework.transaction.TransactionStatus
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 11 more

Can someone tell me what is missing here?

like image 529
amrita thakur Avatar asked Nov 21 '17 02:11

amrita thakur


3 Answers

For Intellij 2018.1 and i guess for early versions, the Run configuration by default gets the Glue 'cucumber.api.spring' , you should switch it for 'com.foreach.cuke'
Go to 'Edit Configurations' - 'Cucumber' - Glue: com.foreach.cuke ...

like image 120
Sergio Gonzalez Avatar answered Nov 03 '22 09:11

Sergio Gonzalez


The below dependency is missing. Default glue cucumber.api.spring is not able to find class transaction so it throws an error. Add dependency to your pom.xml and it will solve your issue

<dependency>
    <groupId>org.springframework</groupId>
     <artifactId>spring-tx</artifactId>
</dependency>
like image 44
Kamoliddin Mirzoev Avatar answered Nov 03 '22 08:11

Kamoliddin Mirzoev


You should switch The Run configuration to 'com.foreach.cuke' instead of 'cucumber.api.spring'..

Go to 'Edit Configurations' - 'Cucumber' - Glue: com.foreach.cuke ...

like image 24
Hussein Bani Odeh Avatar answered Nov 03 '22 09:11

Hussein Bani Odeh