Executed Automation result must show in Testlink

Hey, I wants to connect katalon executed testcase into testlink and for this I have manage to write few code which is somehow run successfully but now found error message that test execution failed. can anyone help me to find the solution?
class NewTestListener {

public static String DEVKEY=“f6e4c2bd12863921c270f1ba7ce40d05”;
public static String URL=“http://localhost/testlink/index.php”;

public static void reportResult(String TestProject,String TestPlan,String Testcase,String Build,String Notes,String Result) throws TestLinkAPIException{
TestLinkAPIClient api=new TestLinkAPIClient(DEVKEY, URL);
api.reportTestCaseResult(TestProject, TestPlan, Testcase, Build, Notes, Result);

}
@BeforeTestCase

def beforetestcase(TestCaseContext testCaseContext) {
println testCaseContext.getTestCaseId()
//println testCaseContext.getTestCaseVariable()
println testCaseContext.getTestCaseStatus()
//testCaseContext.TestCaseId()
String testProject=“Workilo”;
String testPlan=“Workilo Test Plan”;
String testCase=“Verify user will click on next button without change date and time”;
String build=“Beta Testing”;

}

@AfterTestCase
def afterTestcase(TestCaseContext testCaseContext) {
println testCaseContext.getTestCaseId()
println testCaseContext.getTestCaseStatus()

String notes=null;

String result=null;

try{


//WebUI.driver.switchTo().defaultContent();


wait(9)
//wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("+Testlink")));

result= TestLinkAPIResults.TEST_PASSED;

println(result)
notes="Executed successfully";

}

catch(Exception e){

result=TestLinkAPIResults.TEST_FAILED;

notes="Execution failed";

}

}
}

and console log is:

12-13-2018 07:01:52 PM - [PASSED] - Test Cases/Booking Services/Booking after login or without Login/Booking servcies without login/Booking services with valid inputs/click on Next button without changing date and time
12-13-2018 07:01:52 PM - [START] - Start listener action : afterTestcase
12-13-2018 07:01:52 PM - [INFO] - Starting invoke ‘com.kms.katalon.core.annotation.AfterTestCase’ method: ‘NewTestListener.afterTestcase(…)’
12-13-2018 07:01:52 PM - [START] - Start action : Statement - println(testCaseContext.getTestCaseId())
Test Cases/Booking Services/Booking after login or without Login/Booking servcies without login/Booking services with valid inputs/click on Next button without changing date and time
12-13-2018 07:01:52 PM - [END] - End action : Statement - println(testCaseContext.getTestCaseId())
12-13-2018 07:01:52 PM - [START] - Start action : Statement - println(testCaseContext.getTestCaseStatus())
PASSED
12-13-2018 07:01:52 PM - [END] - End action : Statement - println(testCaseContext.getTestCaseStatus())
12-13-2018 07:01:52 PM - [START] - Start action : Statement - notes = null
12-13-2018 07:01:52 PM - [END] - End action : Statement - notes = null
12-13-2018 07:01:52 PM - [START] - Start action : Statement - result = null
12-13-2018 07:01:52 PM - [END] - End action : Statement - result = null
12-13-2018 07:01:52 PM - [START] - Start action : Statement - Try
12-13-2018 07:01:52 PM - [START] - Start action : Statement - wait(9)
12-13-2018 07:01:52 PM - [END] - End action : Statement - wait(9)
12-13-2018 07:01:52 PM - [END] - End action : Statement - Try
12-13-2018 07:01:52 PM - [START] - Start action : Statement - Catch (Exception e)
12-13-2018 07:01:52 PM - [START] - Start action : Statement - result = TEST_FAILED
12-13-2018 07:01:52 PM - [END] - End action : Statement - result = TEST_FAILED
12-13-2018 07:01:52 PM - [START] - Start action : Statement - notes = “Execution failed”
12-13-2018 07:01:52 PM - [INFO] - Invoke ‘com.kms.katalon.core.annotation.AfterTestCase’ method: ‘NewTestListener.afterTestcase(…)’ completed.
12-13-2018 07:01:52 PM - [END] - End action : Statement - notes = “Execution failed”
12-13-2018 07:01:52 PM - [END] - End action : Statement - Catch (Exception e)
12-13-2018 07:01:52 PM - [END] - End listener action : afterTestcase
12-13-2018 07:01:52 PM - [END] - End Test Case : Test Cases/Booking Services/Booking after login or without Login/Booking servcies without login/Booking services with valid inputs/click on Next button without changing date and time

can anyone tell me where I lagging behind?

can anyone help me?

Please add e.printStackTrace() to the catch block and send us the exception’s stack trace.

Thanx devalex for your reply.

I have executed it and there is added few lines in console:

java.lang.IllegalMonitorStateException
at java.lang.Object.wait(Native Method)
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.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrap.invoke(PogoMetaMethodSite.java:190)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:59)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)
at NewTestListener.afterTestcase(NewTestListener.groovy:59)
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.reflection.CachedMethod.invoke(CachedMethod.java:93)
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1215)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:812)
at NewTestListener.invokeMethod(NewTestListener.groovy)
at com.kms.katalon.core.context.internal.TestHooker.invokeMethod(TestHooker.java:131)
at com.kms.katalon.core.context.internal.TestHooker.lambda$3(TestHooker.java:115)
at java.util.ArrayList.forEach(ArrayList.java:1249)
at com.kms.katalon.core.context.internal.TestHooker.invokeContextMethods(TestHooker.java:114)
at com.kms.katalon.core.context.internal.TestListenerCollector.lambda$3(TestListenerCollector.java:60)
at java.util.ArrayList.forEach(ArrayList.java:1249)
at com.kms.katalon.core.context.internal.TestListenerCollector.handleListenerEvent(TestListenerCollector.java:57)
at com.kms.katalon.core.context.internal.ExecutionEventManager.publicEvent(ExecutionEventManager.java:36)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:210)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:99)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:90)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$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:149)
at TempTestCase1544710818617.run(TempTestCase1544710818617.groovy:22)
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)

I am not a very good coder still beginner So may be there is some error in my code which is not showing. So not able to find the solution

The statement wait(9) seems to be incorrect. What did you want to achieve with that statement?

wait for element. okay can you send me the correct code.

In this case, Katalon Studio has a set of convenient waitFor... keywords. Please take a look at docs site:

Or you can use Java’s method Thread.sleep(). The Java’s method Object.wait() is for a very different purpose.

I have combined Selenium coding and katalon coding so may be the reason the code is not executed well. So can you do me a favor to write whole code in katalon so that it will executed well .

Thanks,
Nazneen

Hi all,

TestLink Integration plugin is now available in Katalon Store.

Install here

For more details, refer to this documentation for the plugin.

Cheers,
Katalon Store Team

1 Like