Upload test result and attachment to ALM

Source: Internet
Author: User

Prior to the HP time with ALM, or very useful a very powerful test management tool, at that time in C # in accordance with the ALM API implementation of an upload test results of the program, now posted:

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.IO;usingTdapiolelib;namespacealmconnector{ Public classalmconnection {Privatetdconnection almconnection; PrivateTestsettreemanager Tstreeman; PrivateTestsetfolder RootFolder;
Initialize the connection built into ALM PublicAlmconnection (stringAlmurl_) {almconnection=Newtdconnection (); Almconnection.initconnectionex (ALMURL_); } ~almconnection () {//extremely important to clean up and release resoures when doneDisconnectproject (); Logout (); Almconnection.releaseconnection (); } Public stringSERVERULR {Get { returnAlmconnection.serverurl; } } Public stringUserName {Get { returnAlmconnection.username; } } Public stringDomainName {Get { returnAlmconnection.domainname; } } Public stringProjectName {Get { returnAlmconnection.projectname; } } Publictdapiolelib.list projectlist {Get { returnalmconnection.projectslist; }}//user name password login Public voidLogin (stringUsername_,stringPassword_) {Almconnection.login (username_, Password_); }
Connect to the project and get the project Testsuite RootFolder Public voidConnectproject (stringDomainname_,stringprojectname_) { if(almconnection.connected) {almconnection.connect (domainname_, projectname_); GetRootFolder (); }}//Release Connection Public voidDisconnectproject () {if(almconnection.connected) {almconnection.disconnect (); }}//Log Out Public voidLogout () {if(Almconnection.loggedin) {almconnection.logout (); }}//get to Testset's folder Public BOOLFindtestsetfolder (stringAlmfolderpath, outTestsetfolder Almfolder) {Almfolder=(Testsetfolder) Tstreeman.get_nodebypath (Almfolderpath); return! (Almfolderpath = =NULL); } PublicTestsetfolder GetRootFolder () {if(Tstreeman = =NULL) {Tstreeman=(Testsettreemanager) Almconnection.testsettreemanager; } if(RootFolder = =NULL) {RootFolder=(Testsetfolder) tstreeman.root; } returnRootFolder; }//Establish Testset Public BOOLCreatetestset (Testsetfolder Targetfolder_,stringNewtestsetname_, outTestset 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; }//upload test results to Testset Public BOOLAddtestresulttotestset (Testset tsrun, TestResult tsresult) {tstestfactory tstestfact=tsrun.tstestfactory; Tstest newtstest=Tstestfact.additem (Tsresult.testid); Newtstest.status=Tsresult.teststatus; Newtstest.post (); return true; }//upload attachment to Testset Public voidUploadattachmenttotestset (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 (); } } }}

Upload test result and attachment to ALM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.