[PROBLEMAS] Integração TestLink e Java (Selenium)

13 respostas
A

Alguém já fez esse tipo de integração?

/**
 * Faz a comunicação com o Testlink para reportar os resultados
 * @author Elias Nogueira <[email removido]>
 */
public class ResultadoExecucao implements IConstantes {
	
    /**
     * Método para reportar o resultado do teste automatizado para o Testlink
     * @see http://code.google.com/p/dbfacade-testlink-rpc-api/wiki/Documentation
     * @param projetoTeste nome do Projeto de Teste
     * @param planoTeste nome do Plano de Teste
     * @param casoTeste nome do Caso de Teste
     * @param nomeBuild nome da Build de Teste
     * @param nota nota que será adicionada
     * @param resultado resultado do teste executado
     * @throws TestLinkAPIException erro de comunicação na submissão dos resultados
     */
    public static void reportTestCaseResult(String projetoTeste, String planoTeste, String casoTeste, String nomeBuild, String nota, String resultado) throws TestLinkAPIException {
        
        // Cria uma instância do TestLinkAPIClient para comunicação com o Testlink
        TestLinkAPIClient testlinkAPIClient = new TestLinkAPIClient(DEVKEY, URL);
        // Submete os resultados para o Testlink
        testlinkAPIClient.reportTestCaseResult(projetoTeste, planoTeste, casoTeste, nomeBuild, nota, resultado);

    }

13 Respostas

P

Já cheguei a fazer sim. O TestLink tem uma interface XMLRPC que funciona razoavelmente bem. O único problema que tive foi com relação a uma questão de encoding. Pelo que me lembro havia um bug no processamento da mensagem e se a mensagem tivesse caracteres acentuados um erro era gerado.

A

Estou fazendo o seguinte teste com base na interface que você comentou... Sabe me dizer o que é o DEV_KEY? A mensagem de erro caso o TC falhe é persistida em algum lugar do TestLink?

package teste;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.Map;

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;

public class TestlinkAPIXMLRPCClient {
	// Substitute your Dev Key Here
	public static final String DEV_KEY = "xxxxxxxx";
	// Substitute your Server URL Here
	public static final String SERVER_URL = "http://10.50.18.188/lib/api/xmlrpc.php";

	/**
	 * report test execution to TestLink API
	 * 
	 * @param int tcid
	 * @param int tpid
	 * @param String
	 *            status
	 */
	@SuppressWarnings("rawtypes")
	public static void testLinkReport(int tcid, String status) {
		try {
			XmlRpcClient rpcClient;
			XmlRpcClientConfigImpl config;

			config = new XmlRpcClientConfigImpl();
			config.setServerURL(new URL(SERVER_URL));
			rpcClient = new XmlRpcClient();
			rpcClient.setConfig(config);

			// ////////////////////////
			// Get available projects.
			// ////////////////////////

			ArrayList<Object> params = new ArrayList<Object>();
			Hashtable<String, Object> executionData = new Hashtable<String, Object>();
			executionData.put("devKey", DEV_KEY);
			params.add(executionData);

			Object[] result = (Object[]) rpcClient.execute("tl.getProjects",
					params);

			int idProject = -1;

			// Typically you'd want to validate the result here and probably do
			// something more useful with it
			System.out.println("Result was:\n");
			for (int i = 0; i < result.length; i++) {
				Map item = (Map) result[i];
				System.out.println("Keys: " + item.keySet().toString()
						+ " values: " + item.values().toString());
				if (item.get("name").equals("xxxx")) {
					idProject = Integer.parseInt((String) item.get("id"));
				}
			}

			if (idProject == -1)
				return;

			// ///////////////////////////////////////////
			// Get available test plans in xxx project.
			// DOES ONLY WORK WHEN ALL TEST PLAN NAMES DO
			// NOT CONTAIN ANY SPECIAL CHARS LIKE UMLAUTS
			// ///////////////////////////////////////////

			params = new ArrayList<Object>();
			executionData = new Hashtable<String, Object>();
			executionData.put("devKey", DEV_KEY);
			executionData.put("testprojectid", idProject);
			params.add(executionData);

			result = (Object[]) rpcClient.execute("tl.getProjectTestPlans", params);

			int idTestPlan = -1;

			// Typically you'd want to validate the result here and probably do
			// something more useful with it
			System.out.println("Result was:\n");
			for (int i = 0; i < result.length; i++) {
				Map item = (Map) result[i];
				System.out.println("Keys: " + item.keySet().toString()
						+ " values: " + item.values().toString());

				for (Object key : item.keySet()) {
					Object element = item.get(key);
					if (element instanceof Map == false)
						continue;

					if (((Map) element).get("name").equals("Szenario")) {
						idTestPlan = Integer.parseInt((String) ((Map) element)
								.get("id"));
					}
				}
			}

			if (idTestPlan == -1)
				return;

			// //////////////////
			// Create new build.
			// //////////////////

			params = new ArrayList<Object>();
			executionData = new Hashtable<String, Object>();
			executionData.put("devKey", DEV_KEY);
			executionData.put("testplanid", idTestPlan);
			executionData.put("buildname", "Automatischer Test am "
					+ (new Date()).toString());
			executionData.put("buildnotes", "Notizen...");
			params.add(executionData);

			result = (Object[]) rpcClient.execute("tl.createBuild", params);

			int idBuild = -1;

			// Typically you'd want to validate the result here and probably do
			// something more useful with it
			System.out.println("Result was:\n");
			for (int i = 0; i < result.length; i++) {
				Map item = (Map) result[i];
				System.out.println("Keys: " + item.keySet().toString()
						+ " values: " + item.values().toString());

				if (((Boolean) item.get("status")) == true) {
					idBuild = Integer.parseInt((String) item.get("id"));
				}
			}

			if (idBuild == -1)
				return;

			// Report test case result in new build.
			params = new ArrayList<Object>();
			executionData = new Hashtable<String, Object>();
			executionData.put("devKey", DEV_KEY);
			executionData.put("testcaseid", tcid);
			executionData.put("testplanid", idTestPlan);
			executionData.put("buildid", idBuild);
			executionData.put("status", status);
			executionData.put("notes", "testtest");
			params.add(executionData);

			result = (Object[]) rpcClient.execute("tl.reportTCResult", params);

			// Typically you'd want to validate the result here and probably do
			// something more useful with it
			System.out.println("Result was:\n");
			for (int i = 0; i < result.length; i++) {
				Map item = (Map) result[i];
				System.out.println("Keys: " + item.keySet().toString()
						+ " values: " + item.values().toString());
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (XmlRpcException e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		// Substitute this for a valid tcid and tpid within your project
		TestlinkAPIXMLRPCClient.testLinkReport(4, "b");
	}
}
P

Se não me engano é o conteúdo de uma coluna da tabela de usuários na base do TestLink.

A

?

P

Capítulo 8 do manual:

8.1 User account settings
Every guest can create own account on login page.
The auto-create feature can be disabled by configuration. There is also configurable
default role parameter (‘guest’ by default).

Every user on the system will be able to edit their own information via the Account settings
window (‘Personal’ link in menu bar). He can modify own Name, email address, password and
generate API key (if enabled).

TestLink allows users with administrator rights to create, edit, and delete users within the
system. However, TestLink does not allow administrators to view or edit user’s passwords. If
users forget their passwords there is link on the login screen, that will mail the user their
password based upon their user name and the email address they entered

A

Pode mandar o link do manual por gentileza?

P

http://www.teamst.org/index.php/doc

A

Imaginemos um cenário ao qual utliza-se o Hudson, foi programado para que o teste seja executado de 30 em 30 dias… Neste caso não tem id do usuário…

abs,

A

Por gentileza qual API vc utilizou pra fazer a integração do Testlink com o Selenium?

A

Alguém pode ajudar?

A

A melhor e mais fácil maneira de se fazer isso, é simplesmente persistindo na tabela executions da base de dados do Testlink, os valores necessários para alimentar seu INSERT o testador pode conseguir manualmente na própria tela do Testlink mapeando através de levar a seta do mouse sobre os links e ver na barra de status o id correlacionado.

abs,
AS.

A

Para quem estiver passando por esta dificuldade, conseguí integrar também através da Testlink Java API encontrada no link http://testlinkjavaapi.sourceforge.net/.

A

A API do proprio Testlink 1.9.0 vem se compartando com demasiada intermitencia de funcionamento… Alguém já integrou de forma diferente?

Criado 11 de maio de 2011
Ultima resposta 6 de jun. de 2012
Respostas 13
Participantes 2