使用api导入testlink用例
来源:互联网 发布:java string转int 编辑:程序博客网 时间:2024/06/05 06:02
需求:因为之前把用例都写在了bugfree,现在要导导testlink上,bugfree上用例前提、步骤、结果都是在一块的。。比较尴尬
实现步骤如下:
1、vi /var/www/html/testlink/config.inc.php
修改设置:$tlCfg->exec_cfg->enable_test_automation = ENABLED
2、testlink上生成api key

3、调api(需要知道账户名、projectId、suiteId)
import br.eti.kinoshita.testlinkjavaapi.TestLinkAPI;import br.eti.kinoshita.testlinkjavaapi.constants.ActionOnDuplicate;import br.eti.kinoshita.testlinkjavaapi.constants.ExecutionType;import br.eti.kinoshita.testlinkjavaapi.constants.TestCaseStatus;import br.eti.kinoshita.testlinkjavaapi.constants.TestImportance;import br.eti.kinoshita.testlinkjavaapi.model.TestCase;import br.eti.kinoshita.testlinkjavaapi.model.TestCaseStep;import br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIException;import jxl.Sheet;import jxl.Workbook;import jxl.read.biff.BiffException;import org.dom4j.Document;import org.dom4j.DocumentHelper;import org.dom4j.Element;import org.dom4j.io.XMLWriter;import org.testng.annotations.DataProvider;import org.testng.annotations.Test;import java.io.*;import java.net.MalformedURLException;import java.net.URL;import java.util.ArrayList;import java.util.List;/** * Created by guoying on 2017/6/12. */public class CreateTestCase { Sheet sheetToEdit; static Workbook rwb; TestLinkAPI api = null; @DataProvider(name = "data") public Object[][] getDate() throws IOException, BiffException { InputStream stream = new FileInputStream("caselist.xls"); rwb = Workbook.getWorkbook(stream); Object[][] objects = null; for (int j = 0; j < rwb.getNumberOfSheets(); j++) { sheetToEdit = rwb.getSheet(j); System.out.println(sheetToEdit.getName()); objects = new Object[sheetToEdit.getRows()][7]; for (int n = 0; n < sheetToEdit.getRows() - 1; n++) { String forProjectNo = sheetToEdit.getCell(0, n + 1).getContents().toString(); String forSuiteId = sheetToEdit.getCell(1, n + 1).getContents().toString(); String forYouXianJi = sheetToEdit.getCell(2, n + 1).getContents().toString(); String forTitle = sheetToEdit.getCell(3, n + 1).getContents().toString(); String forStep = sheetToEdit.getCell(4, n + 1).getContents().toString(); String pre = forStep.substring(forStep.indexOf("前置条件"), forStep.indexOf("操作步骤")); String stepAll = forStep.substring(forStep.indexOf("操作步骤"), forStep.indexOf("预期结果")); String result = forStep.substring(forStep.indexOf("预期结果"), forStep.length()); objects[n][0] = forProjectNo; objects[n][1] = forSuiteId; objects[n][2] = forTitle; objects[n][3] = pre; objects[n][4] = stepAll; objects[n][5] = result; objects[n][6] = forYouXianJi; } } return objects; } public void init() throws MalformedURLException { String url = "http://xxx.xxx.xxx.xxx:port/testlink/lib/api/xmlrpc/v1/xmlrpc.php"; String devKey = "b63c521dfc5a249609805df6a07d7c7f"; 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.ping()); } @Test(dataProvider = "data") public void create(String projectId, String suiteId, String title, String pre, String stepAll, String result, String youXinaJi) throws IOException { List<TestCaseStep> steps = new ArrayList<TestCaseStep>(); TestCaseStep step = new TestCaseStep(); step.setNumber(1); step.setExpectedResults(result); step.setExecutionType(ExecutionType.MANUAL); step.setActions(stepAll); steps.add(step); init(); TestImportance importance = TestImportance.HIGH; if (youXinaJi.equals("1")){ importance = TestImportance.HIGH; }else if (youXinaJi.equals("2")){ importance = TestImportance.MEDIUM; }else if (youXinaJi.equals("3")){ importance = TestImportance.LOW; } TestCase tc = api.createTestCase( title, // testCaseName Integer.parseInt(suiteId), // testSuiteId Integer.parseInt(projectId), // testProjectId "admin", // authorLogin "No summary", // summary steps, // steps pre, // preconditions TestCaseStatus.REVIEW_IN_PROGRESS, // importance importance, // execution ExecutionType.MANUAL, // order null, // internalId null, // checkDuplicatedName null, ActionOnDuplicate.BLOCK); // actionOnDuplicatedName System.out.println("Test case with steps created"); }}
api:
http://kinow.github.io/testlink-java-api/sample4.html
阅读全文
0 0
- 使用api导入testlink用例
- testlink使用
- testlink使用
- Excel导入TestLink
- Testlink(4)——使用TestLink
- TESTLINK使用笔记
- Testlink使用经验总结
- Testlink安装使用
- Testlink使用小结
- testlink使用流程
- testlink使用_李晓亭
- Testlink使用流程简述
- Testlink 使用步骤
- testlink的使用
- Testlink使用流程简述
- testlink的使用步骤
- testLink的使用
- Testlink的使用
- 多种方式获取文件夹里的文件名称
- try-catch-finally 规则( 异常处理语句的语法规则 )
- angluarjs flask 前后台数据交互传递 异步请求
- Java多线程开发系列之四:玩转多线程(线程的控制1)
- 一款用于在Android设备上获取照片(拍照或从相册、文件中选择)、裁剪图片、压缩图片的开源工具库
- 使用api导入testlink用例
- 51nod:数字1的数量(线性dp or 数位dp)
- kettle转换控件的使用与经验分享
- win7系统中便笺元数据已损坏该怎么办?
- App架构设计经验谈:接口的设计
- Android butterknife框架配置
- Android 中 Fragment 嵌套 Fragment使用存在的bug附完美解决方案
- 关于c语言命令行参数的问题
- erlang gen_server 测试