BDD Testing - Unable to get past NoClassDefFoundError: TestObject error


#1

Am trying out the new BDD cucumber feature. I’ve followed the sample feature file and step definition script available on https://docs.katalon.com/display/KD/BDD+Testing+Framework. The problem am facing is during execution of the feature file. It always errors out immediately after run with this error. Is anyone able to add feature files to an already Web testing project and run it successfully?

**


**

09-11-2018 10:41:36 AM - [START] - Start Test Case : Verification
09-11-2018 10:41:36 AM - [START] - Start action : runFeatureFile
09-11-2018 10:41:36 AM - [INFO] - Starting run keyword runFeatureFile: ‘Include/features/login.feature’ and extract report to folder: ‘C:\Users\jn6389\AppData\Local\Temp\Katalon\Include\features\login.feature\20180911_104133/cucumber_report/1536676896947’…
09-11-2018 10:41:37 AM - [FAILED] - Keyword runFeatureFile was failed (Root cause: java.lang.NoClassDefFoundError: TestObject)
09-11-2018 10:41:37 AM - [END] - End action : runFeatureFile
09-11-2018 10:41:37 AM - [FAILED] - Verification FAILED because (of) (Stack trace: com.kms.katalon.core.exception.StepFailedException: Keyword runFeatureFile was failed (Root cause: java.lang.NoClassDefFoundError: TestObject)
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:56)
at com.kms.katalon.core.keyword.internal.KeywordMain$runKeyword.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:141)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFile(CucumberBuiltinKeywords.groovy:45)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$runFeatureFile$0.callStatic(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:56)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:194)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:214)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFile(CucumberBuiltinKeywords.groovy:95)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$runFeatureFile.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at WSVerification1536676896708.run(WSVerification1536676896708:2)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:183)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:108)
at com.kms.katalon.core.main.WSVerificationExecutor.runScript(WSVerificationExecutor.java:145)
at com.kms.katalon.core.main.WSVerificationExecutor.doExecute(WSVerificationExecutor.java:139)
at com.kms.katalon.core.main.WSVerificationExecutor.processExecutionPhase(WSVerificationExecutor.java:122)
at com.kms.katalon.core.main.WSVerificationExecutor.accessMainPhase(WSVerificationExecutor.java:114)
at com.kms.katalon.core.main.WSVerificationExecutor.execute(WSVerificationExecutor.java:102)
at com.kms.katalon.core.main.TestCaseMain.runFeatureFile(TestCaseMain.java:129)
at com.kms.katalon.core.main.TestCaseMain$runFeatureFile$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
at TempTempCase1536676893874.run(TempTempCase1536676893874.groovy:21)
at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
at groovy.lang.GroovyShell.run(GroovyShell.java:518)
at groovy.lang.GroovyShell.run(GroovyShell.java:507)
at groovy.ui.GroovyMain.processOnce(GroovyMain.java:653)
at groovy.ui.GroovyMain.run(GroovyMain.java:384)
at groovy.ui.GroovyMain.process(GroovyMain.java:370)
at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129)
at groovy.ui.GroovyMain.main(GroovyMain.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)
at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
)
09-11-2018 10:41:37 AM - [END] - End Test Case : Verification

image.png

feature_file.JPG


#2

Same problem here… :frowning: in my case was caused by Root cause: java.lang.NoClassDefFoundError: RequestObject instead of TestObject, funny because it works in my machine with exactly the same code and it doesn’t in my workmate machine.


#3

Guys, please be aware, there is a new forum category for BDD:


#4

Russ Thomas said:

Guys, please be aware, there is a new forum category for BDD:

https://forum.katalon.com/categories/bdd-testing

Sorry Russ, but I’m not able to start any topic in there :frowning:


#5

Really? Hmm… that’s a pain. I’ll drop them a line.


#6

BDD Forum category should be fixed now.


#7

I encountered the similar issue and resolved it.

See the following:


#9

NoClassDefFoundError in Java comes when Java Virtual Machine is not able to find a particular class at runtime which was available at compile time. After you compile your code, you end up with .class files for each class in your program. These binary files are the bytecode that Java interprets to execute your program. The NoClassDefFoundError indicates that the classloader (in this case java.net.URLClassLoader), which is responsible for dynamically loading classes, cannot find the .class file for the class that you’re trying to use.

NoClassDefFoundError can occur for multiple reasons like

  • ClassNotFoundException – .class not found for that referenced class irrespective of whether it is available at compile time or not(i.e base/child class).
  • Class file located, but Exception raised while initializing static variables
  • Class file located, Exception raised while initializing static blocks