Connect Automation result to Test link test management tool


#1

Hey could you please help me to connect my katalon automation result into testlink test management tool?
I found only selenium can be connected with testlink but all my test execution is done on katalon. So please help me on this
is there any one to help me out?


#2

Based on this tutorial : https://www.softwaretestinghelp.com/testlink-tutorial-3/, you can use Katalon listeners especially @afterTestCase hook to push results directly to TestLink.

Sample code:

@AfterTestCase
def afterTestcase(TestCaseContext testCaseContext) {
	result = (testCaseContext.getTestCaseStatus() == 'FAILED') ? TestLinkAPIResults.TEST_FAILED : TestLinkAPIResults.TEST_PASSED;
	reportResult(testProject, testPlan, testCase, build, notes, result);
}

#3

Hey Vinh,

Thanks for your reply. can you please elaborate more?


#4

I have created new test listener and add your code but these keywords have not been recognised .please view the below code:

class NewTestListener {
/**
* Executes after every test case ends.
* @param testCaseContext related information of the executed test case.
*/
@AfterTestCase
def afterTestcase(TestCaseContext testCaseContext) {
println testCaseContext.getTestCaseId()
println testCaseContext.getTestCaseStatus()

		result = (testCaseContext.getTestCaseStatus() == 'FAILED') ? TestLinkAPIResults.TEST_FAILED : TestLinkAPIResults.TEST_PASSED;
		reportResult(testProject, testPlan, testCase, build, notes, result);

also my question is where I place the api code generated by testlink and adding only test lisner can be able to execute my automate testcase?

I am confused please help.


#5

You need to pass other required settings from TestLink to these variables: testProject, testCase, build, notes.

Replacing these variables with the actual TestLink project information, including DEVKEY and URL of your TestLink application. To use TestLink SDK, first you need to import them to Katalon project.

import testlink.api.java.client.TestLinkAPIClient;
import testlink.api.java.client.TestLinkAPIException;
import testlink.api.java.client.TestLinkAPIResults;

public static String DEVKEY="2f404203b306bd8dd811a7f824c194d0";
public static String URL="http://localhost/testlink/lib/api/xmlrpc/v1/xmlrpc.php";

String testProject="Gmail";
String testPlan="SampleTestPlan";
String testCase="GmailLogin1";
String build="SampleBuild";
String notes=null;

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);
}

#6

I have set all the library files from setting and execute this piece of code in test listener then all working good but showing error message on public static void…

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile

import internal.GlobalVariable as GlobalVariable

import com.kms.katalon.core.annotation.BeforeTestCase
import com.kms.katalon.core.annotation.BeforeTestSuite
import com.kms.katalon.core.annotation.AfterTestCase
import com.kms.katalon.core.annotation.AfterTestSuite
import com.kms.katalon.core.context.TestCaseContext
import com.kms.katalon.core.context.TestSuiteContext
import testlink.api.java.client.TestLinkAPIClient;
import testlink.api.java.client.TestLinkAPIException;
import testlink.api.java.client.TestLinkAPIResults;

class NewTestListener {
/**
* Executes after every test case ends.
* @param testCaseContext related information of the executed test case.
*/
public static String DEVKEY=“f6e4c2bd12863921c270f1ba7ce40d05”;
public static String URL=“http://localhost/testlink/lib/api/xmlrpc/v1/xmlrpc.php”;

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";
String notes=null;


@AfterTestCase
	def afterTestcase(TestCaseContext testCaseContext) {
		println testCaseContext.getTestCaseId()
		println testCaseContext.getTestCaseStatus()
		
	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);
	}
		
}

}

Did I place the code in right place or not?

Also I am very thank full to you for your help. It will really help me alot to execute my test cases. :slight_smile:

Thanks


#7

okay so far now, i am able to resolve the above error but still my automation script is not connected with testlink. I have change the following things according to my projects mentioned below:

public static String DEVKEY=“f6e4c2bd12863921c270f1ba7ce40d05”;
public static String URL=“http://localhost/testlink/lib/api/xmlrpc/v1/xmlrpc.php”;

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";
String notes=null;

Only url is remain same which you have posted. So should I change it? if yes then what will be the url of my project?

Here is my code:
class NewTestListener {
public static String DEVKEY=“f6e4c2bd12863921c270f1ba7ce40d05”;
public static String URL=“http://localhost/testlink/lib/api/xmlrpc/v1/xmlrpc.php”;

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";
String notes=null;

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);
	
	
	}

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

}
Can you please help me @Vinh_Nguyen


#8

It’s TestLink URL in your network.


#9

Teslink URL is http://localhost/testlink/index.php.

Still I found various thing is missing that’s the reason Automation script not connected. Plz help


#10

Provide some logs…


#11


#12


#13

any help from anyone? I am stuck now completely.


#14

Hey I have again added few codes in my existing code and now the test result is showing fail. here is my attached code:

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?


#15

Hello every one, and thanks for your efforta until now. I ll try to modify and adapt your examples to see if its gonna work for me. And ofcourse in case of succefull implementation I ll post Back here.
Untill then I d like to ask if anyone had some luck with this task anyway…
Thanks


#16

Ιt finally works. Anyone interested just pm me… Cheers


#17

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