之前在HP的时候用ALM,还是很好用的功能很强大的一个测试管理工具,当时用C#依照ALM的API实现了一个上传测试结果的程序,现在贴出来:

这个程序的使用方式很自由,使得ALM几乎可以和所有测试工具做集成,只要测试工具能够提供xml的测试结果

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO; using TDAPIOLELib; namespace ALMConnector
{
public class ALMConnection
{
private TDConnection almConnection;
private TestSetTreeManager tsTreeMan;
private TestSetFolder rootFolder;

// 初始化建立到ALM的connection
public ALMConnection(string almURL_)
{
almConnection = new TDConnection();
almConnection.InitConnectionEx(almURL_);
} ~ALMConnection()
{
// Extremely important to clean up and release resoures when done
DisconnectProject();
Logout();
almConnection.ReleaseConnection();
} public string ServerULR
{
get
{
return almConnection.ServerURL;
}
} public string UserName
{
get
{
return almConnection.UserName;
}
} public string DomainName
{
get
{
return almConnection.DomainName;
}
} public string ProjectName
{
get
{
return almConnection.ProjectName;
}
} public TDAPIOLELib.List ProjectList
{
get
{
return almConnection.ProjectsList;
}
}
//用户名密码登陆
public void Login(string userName_, string password_)
{
almConnection.Login(userName_, password_);
}

//连接到项目,得到项目的testsuite rootfolder
public void ConnectProject(string domainName_, string projectName_)
{
if (almConnection.Connected)
{
almConnection.Connect(domainName_, projectName_);
GetRootFolder();
}
}
//释放connection
public void DisconnectProject()
{
if (almConnection.Connected)
{
almConnection.Disconnect();
}
}
//登出
public void Logout()
{
if (almConnection.LoggedIn)
{
almConnection.Logout();
}
}
//获取到testset的folder
public bool FindTestSetFolder(string almFolderPath, out TestSetFolder almFolder)
{
almFolder = (TestSetFolder)tsTreeMan.get_NodeByPath(almFolderPath);
return !(almFolderPath == null);
} public TestSetFolder GetRootFolder()
{
if (tsTreeMan == null)
{
tsTreeMan = (TestSetTreeManager)almConnection.TestSetTreeManager;
}
if (rootFolder == null)
{
rootFolder = (TestSetFolder)tsTreeMan.Root;
}
return rootFolder;
}
//建立testset
public bool CreateTestSet(TestSetFolder targetFolder_, string newTestSetName_, out TestSet testSetInstance_)
{
List tsList = targetFolder_.FindTestSets(newTestSetName_);
if (tsList == null)
{
TestSetFactory tsFact = targetFolder_.TestSetFactory;
TestSet tsNew = tsFact.AddItem(DBNull.Value);
tsNew.Name = newTestSetName_;
tsNew.Status = "Open";
tsNew.Post(); testSetInstance_ = tsNew; return true;
}
else if (tsList.Count == )
{
testSetInstance_ = tsList[];
}
else
{
testSetInstance_ = null;
} return false;
}
//上传测试结果到testset
public bool AddTestResultToTestSet(TestSet tsRun, TestResult tsResult)
{
TSTestFactory tsTestFact = tsRun.TSTestFactory;
TSTest newTSTest = tsTestFact.AddItem(tsResult.TestId);
newTSTest.Status = tsResult.TestStatus;
newTSTest.Post(); return true;
}
//上传attachment到testset
public void UploadAttachmentToTestSet(TestSet tsRun, String reportPath)
{
TestSet tSet = null;
AttachmentFactory attfat = null;
Attachment attobj = null;
if (File.Exists(reportPath))
{
Console.WriteLine("Find Attachment File,Uploading ...");
tSet = tsRun;
attfat = tSet.Attachments;
attobj = attfat.AddItem(System.DBNull.Value);
attobj.FileName = reportPath;
attobj.Type = ;
attobj.Post();
}
}
}
}

上传Test Result和attachment到ALM的更多相关文章

  1. ASP.NET、JAVA跨服务器远程上传文件(图片)的相关解决方案整合

    一.图片提交例: A端--提交图片 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string u ...

  2. 【完整靠谱版】结合公司项目,仔细总结自己使用百度编辑器实现FTP上传的完整过程

    说在前面 工作中会遇到很多需要使用富文本编辑器的地方,比如我现在发布这篇文章离不开这个神器,而且现在网上编辑器太多了.记得之前,由于工作需要自己封装过一个编辑器的公共插件,是用ckeditor改版的, ...

  3. NET实现微信公共平台上传下载多媒体文件(转)

    举个例子,有人对着我们的公共微信号拍个照片发送过来,然后我们处理这个照片,比如进行ocr识别字(随后就会降到这个例子),或者人脸识别,或者拍照取证等,这些功能都是相当有用的.那么我们现在就要分析一下这 ...

  4. Webwork 学习之路【07】文件上传下载

    Web上传和下载应该是很普遍的一个需求,无论是小型网站还是大并发访问的交易网站.WebWork 当然也提供了很友好的拦截器来实现对文件的上传,让我们可以专注与业务逻辑的设计和实现,在实现上传和下载时顺 ...

  5. 【UEditor】 UEditor整合项目上传资源到阿里云服务器

    目录 关于此文 下载源码 JSP代码 Java代码 阿里云jar包引入配置 成功啦! 回到顶部 关于此文 项目中要实现编辑器生成带格式的html文档,存入模板,最后生成html的URL,所以选择了UE ...

  6. ASP.NET跨服务器上传文件的相关解决方案

    第一种:通过FTP来上传文件 首先,在另外一台服务器上设置好FTP服务,并创建好允许上传的用户和密码,然后,在ASP.NET里就可以直接将文件上传到这台 FTP 服务器上了.代码如下: <%@ ...

  7. java实现多线程断点续传,上传下载

    采用apache 的 commons-net-ftp-ftpclient import java.io.File; import java.io.FileOutputStream; import ja ...

  8. 微信公共服务平台开发(.Net 的实现)8-------处理图片(上传下载发送)

    举个例子,有人对着我们的公共微信号拍个照片发送过来,然后我们处理这个照片,比如进行ocr识别字(随后就会降到这个例子),或者人脸识别,或者拍照取证等,这些功能都是相当有用的.那么我们现在就要分析一下这 ...

  9. phpcms前端页面上传文件

    PHPCMS其实有一个叫做附件的模块,上传用的就是这个东西,现在我们来看一下对应的文件:phpcms\modules\attachment \attachments.php就是这个文件,大概在29行上 ...

随机推荐

  1. ntelliJ IDEA 14 注册码

    user or company nameo license key63625-MQ87K-3SRZ2-8MQYB-6NQZC-2Z8K6

  2. 在db2中 两个数据库之间的两个表的联合查询

    大家好,今天遇到了在db2中 两个数据库之间的两个表的联合查询 我知道oracle中有dblink,可是不知到db2的两个数据库联合查询怎么处理我找了类似于比如两个数据库: db1,db2用户名密码s ...

  3. 277. Find the Celebrity

    题目: Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, there may exi ...

  4. 275. H-Index II

    题目: Follow up for H-Index: What if the citations array is sorted in ascending order? Could you optim ...

  5. myplan

    告警集成平台 – OneAlert(空) JumpServer-开源跳板机(堡垒机)搭建(空) Suricata入侵检测.防御系统搭建(空) Snort入侵检测系统搭建(空) OpenVas开放式漏洞 ...

  6. Android应用开发学习笔记之菜单

    作者:刘昊昱 博客:http://blog.csdn.net/liuhaoyutz Android中的菜单分为选项菜单(OptionMenu)和上下文菜单(Context Menu).通常使用菜单资源 ...

  7. [转]matlab如何复制spectrum scope的图

    2014-03-17 22:23:01 来自:http://www.ilovematlab.cn/thread-38713-1-1.html 如何将spectrum scope的图复制出来? 解决方法 ...

  8. MyBatis的foreach语句详解 list array map

    foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合.foreach元素的属性主要有 item,index,collection,open,separator,close.it ...

  9. Python 中 os.path模板

    os.path.abspath(path) #返回绝对路径 os.path.basename(path) #返回文件名 os.path.commonprefix(list) #返回list(多个路径) ...

  10. MongoDB安装Windows服务

    由于官方下载较慢.这里提供一个个人百度共享网盘地址: http://pan.baidu.com/s/1mhHW0nI mongodb-win32-x86_64-3.2.3 使用以下命令将MongoDB ...