zoukankan      html  css  js  c++  java
  • 上传Test Result和attachment到ALM

    之前在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 == 1) { testSetInstance_ = tsList[1]; } 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 = 1; attobj.Post(); } } } }
  • 相关阅读:
    51CTO资料索引 很不错
    extern和extern“c"作用详解 以及C和C++混合编程 在文章:3.深层揭密extern "C" 部分可以看到 .
    用VC++实现图像检索技术(转)
    OpenSceneGraph FAQ
    NeHe OpenGL教程 02 渲染第一个多边形
    C++经验谈(摘抄)
    利用条件编译实现工程定制版本的自动输出
    没有文件扩展".js"的脚本引擎 解决办法
    OpenGL FAQ
    NeHe OpenGL教程 01 创建OpenGL窗口
  • 原文地址:https://www.cnblogs.com/goldenRazor/p/4868836.html
Copyright © 2011-2022 走看看