Thursday 28 July 2011

TestLinkAPI missing custom fields

I have this sample program using the TestLinkAPI v1.9.2-2. I want to return the list of custom fields for a TestLink projects test cases.

package testlink;

import br.eti.kinoshita.testlinkjavaapi.TestLinkAPI;
import br.eti.kinoshita.testlinkjavaapi.TestLinkAPIException;
import br.eti.kinoshita.testlinkjavaapi.model.TestCase;
import br.eti.kinoshita.testlinkjavaapi.model.TestSuite;
import br.eti.kinoshita.testlinkjavaapi.util.Util;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Hello world!
 *        http://testlinkjavaapi.sourceforge.net/sample1.html
 */
public class App 
{
    public static void main( String[] args )
    {
        System.out.println( "Hello World!" );

        String url = "http://xx/testlink/lib/api/xmlrpc.php";
        String devKey = "xx";
        TestLinkAPI api = null;

        URL testlinkURL = null;

        try
        {
                testlinkURL = new URL(url);
        }
        catch ( MalformedURLException mue )
        {
                mue.printStackTrace( System.err );
                System.exit(-1);
        }

        try
        {
                api = new TestLinkAPI(testlinkURL, devKey);
        }
        catch( TestLinkAPIException te)
        {
                te.printStackTrace( System.err );
                System.exit(-1);
        }

        System.out.println(api.sayHello());
        System.out.println(api.getTestProjectByName("xx"));
        TestSuite suite = api.getFirstLevelTestSuitesForTestProject(new Integer(1))[0];
        TestCase[] testcases = api.getTestCasesForTestSuite(suite.getId(), true, null);
        for(int c = 0;c

The exported xml output from TestLink for the suite is



	
	
	
	
	
	
	


	
		
		
		
		
		
	



	
	
	
	
	
	
	


	
		
		
		
		
		
	


But the program output is

Hello!
TestProject [id=1, name=Touchpoint, prefix=TP, notes=, enableRequirements=true, enableTestPriority=true, enableAutomation=true, enableInventory=true, isActive=true, isPublic=true]
Install
TestCase [id=3, name=Import Indexes, testSuiteId=null, testProjectId=null, authorLogin=null, summary=null, steps=[], preconditions=null, testImportance=null, executionType=null, order=100, internalId=null, checkDuplicatedName=null, actionOnDuplicatedName=null, versionId=2, version=null, parentId=2, customFields=[], executionStatus=n]
n
[]
TestCase [id=5, name=Import Models, testSuiteId=null, testProjectId=null, authorLogin=null, summary=null, steps=[], preconditions=null, testImportance=null, executionType=null, order=101, internalId=null, checkDuplicatedName=null, actionOnDuplicatedName=null, versionId=2, version=null, parentId=2, customFields=[], executionStatus=n]
n
There are no Custom Fields listed.

Testlink Automated Tests

Looking at how to define automated test cases within the TestLink tool this morning so I installed v1.9.3 painlessly. As per chapter 4 of the Jenkins TestLink Plug-in: The Definitive Guide the trick is to define and assign a 'Custom Field' to record the java class name or testng suite. Since we're not using jenkins I'll probally follow the basic steps and use http://code.google.com/p/testlink-api-java-client/ to pull the details from Testlink within my bamboo build.

In the testlink/config.inc.php update the following settings to enable the API and enable test automation


/** XML-RPC API availability (disabled by default) */
$tlCfg->api->enabled = TRUE;

/* [Test Executions] */
// ENABLED -> enable XML-RPC calls to external test automation server new buttons will be displayed on execution pages
// DISABLED -> disable
$tlCfg->exec_cfg->enable_test_automation = ENABLED;