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(); } } } }
  • 相关阅读:
    LDA线性判别分析原理及python应用(葡萄酒案例分析)
    运用sklearn进行主成分分析(PCA)代码实现
    主成分分析PCA数据降维原理及python应用(葡萄酒案例分析)
    Eclipse开发Android项目报错解决方案详细教程,最新版一篇就够了!
    深度学习模型调优方法(Deep Learning学习记录)
    mnist手写数字识别——深度学习入门项目(tensorflow+keras+Sequential模型)
    熵、联和熵与条件熵、交叉熵与相对熵是什么呢?详细解读这里有!
    2020 年百度之星程序设计大赛
    2020年百度之星程序设计大赛-初赛二
    Pytorch实现基于卷积神经网络的面部表情识别(详细步骤)
  • 原文地址:https://www.cnblogs.com/goldenRazor/p/4868836.html
Copyright © 2011-2022 走看看