2015-03-06 19 views
6

Ben aşağıdaki kodu çalıştırın ama hiçbir şey ALM da kendini göstermektedir:ALM OTA'da C# ile test kümesine nasıl ek eklenir?

AttachmentFactory attachmentFactory = (AttachmentFactory)tsTest.Attachments; 
TDAPIOLELib.Attachment attachment = (TDAPIOLELib.Attachment)attachmentFactory.AddItem("test"); 
attachment.Post(); 

ikinci satırında AddItem yöntemi "ItemData nesne" için soruyor ama bu tam olarak ne olduğunu bilmiyorsunuz. HP, böyle bir zayıf belgeye sahip olduğundan, gerçekten açıklayan hiçbir şey yoktur. Herkes tarafından nasıl programlanacağını biliyor mu? HP ALM'de bir test çalıştırmasına bir dosya eki ekleme?

+0

herkes:

try { if (qcConn.Connected) { string testFolder = @"Root\YourFolder"; TestSetTreeManager tsTreeMgr = (TestSetTreeManager)qcConn.TestSetTreeManager; TestSetFolder tsFolder = (TestSetFolder)tsTreeMgr.get_NodeByPath(testFolder); AttachmentFactory attchFactory = (AttachmentFactory)tsFolder.Attachments; List tsList = tsFolder.FindTestSets("YourTestNameHere", false, null); foreach (TestSet ts in tsList) { TestSetFolder tstFolder = (TestSetFolder)ts.TestSetFolder; TSTestFactory tsTestFactory = (TSTestFactory)ts.TSTestFactory; List mylist = tsTestFactory.NewList(""); foreach (TSTest tsTest in mylist) { RunFactory runFactory = (RunFactory)tsTest.RunFactory; Run run = (Run)runFactory.AddItem("NameYouWantDisplayedInALMRuns"); run.CopyDesignSteps(); //runResult just tells me if overall my test run passes or fails - it's not built in. It was my way of tracking things though the code. if(runResult) run.Status = "Failed"; else run.Status = "Passed"; run.Post(); //Code to attach an actual file to the test run. AttachmentFactory attachmentFactory = (AttachmentFactory)run.Attachments; TDAPIOLELib.Attachment attachment = (TDAPIOLELib.Attachment)attachmentFactory.AddItem(System.DBNull.Value); attachment.Description = "Attach via c#"; attachment.Type = 1; attachment.FileName = "C:\\Program Files\\ApplicationName\\demoAttach.txt"; attachment.Post(); //Code to attach a URL to the test run AttachmentFactory attachmentFactory = (AttachmentFactory)run.Attachments; TDAPIOLELib.Attachment attachment = (TDAPIOLELib.Attachment)attachmentFactory.AddItem(System.DBNull.Value); //Yes, set the description and FileName to the URL. attachment.Description = "http://www.google.com"; attachment.Type = 2; attachment.FileName = "http://www.google.com"; attachment.Post(); //If your testset has multiple steps and you want to update //them to pass or fail StepFactory rsFactory = (StepFactory)run.StepFactory; dynamic rdata_stepList = rsFactory.NewList(""); var rstepList = (TDAPIOLELib.List)rdata_stepList; foreach (dynamic rstep in rstepList) { if (SomeConditionFailed) rstep.Status = "Failed"; else rstep.Status = "Passed"; rstep.Post(); } else { rstep.Status = "No Run"; rstep.Post(); } } } } } } 

cevap

4

çok fazla acı ve araştırmadan sonra. Eminim ki bunu daha verimli hale getirmenin başka yolları da vardır, ancak HP'nin belgeleri gezegendeki en kötüsü olduğundan, bu benim elde ettiğim en iyisidir. Herkesin daha iyi bir yolu varsa bunu görmek isterdim, lütfen onu gönderin!

Umarım bu yardımcı olur!

Req req = Globals.Connection.ReqFactory.Item(*ID*)); 
VersionControl versionControl = ((IVersionedEntity)req).VC as VersionControl; 
versionControl.CheckOut(string.Empty); 
AttachmentFactory attFac = req.Attachments; 
Attachment att = (Attachment)attFac.AddItem(System.DBNull.Value); 
att.Description = "*Your description here"; 
att.Type = (int)TDAPI_ATTACH_TYPE.TDATT_FILE; //for URL, change here 
att.FileName = "*Your path including filename here*"; 
att.Post(); 
versionControl.CheckIn("*Your check-in comment here*"); 
+1

Java null türü için: new Variant (Variant.Type.VT_NULL) birisinin yardımcı olacağını umuyorum :) –

1

Benzer bir şey yaptım, ancak Python'da ve Test Adımlarına karşı, kodum olmasa bile & kopyalayıp yapıştırabilirsiniz, bu sizi doğru yöne gösterebilir. Şimdi

file = attachmentFactory.AddItem() 

:

attachmentFactory.AddItem(filename) 

Çağrı hiçbir parametrelerle fonksiyonu (C# ile OTA API hiç kullanılmamış beri ya boş paramer, söyleyemem): Yerine çağıran

dosyayı ek öğeye ve özelliklerinin geri kalanına atayın:

file.Filename = "C:\\Users\\myUser\\just\\an\\example\\path" + fileName 
file.Description = "File description" 
file.Type=1 
file.Post() 

Tür, bu bir yerel olduğunu belirtir dosya ve bir URL değil.

+1

Dostum, çok teşekkürler! Buna ihtiyacım vardı! – BUInvent

0

İnternet hakkında değerli bir bilgi yok! OTA belgelerinde bazı kazı sonra ben bu bulduk:

AttachmentFactory attachmentFactory = (AttachmentFactory)TstTest.Attachments; 
      TDAPIOLELib.Attachment attachment = (TDAPIOLELib.Attachment)attachmentFactory.AddItem("demoAttach.txt"); 
      attachment.Description = "Bug Sample Attachment"; 
      attachment.Post(); 
      IExtendedStorage exStrg = attachment.AttachmentStorage; 
      exStrg.ClientPath = "E:\\TestData"; 
      exStrg.Save("demoAttach.txt", true); 

aslında VB komut şeklinde ama C# dönüştürmeyi başardı. OTA referansı: bir cevap bulduk

'----------------------------------------- 
'Use Bug.Attachments to 
' get the bug attachment factory. 
    Set attachFact = bugObj.Attachments 
'Add a new extended storage object,an attachment 
' named SampleAttachment.txt. 
    Set attachObj = attachFact.AddItem("SampleAttachment.txt") 
' Modify the attachment description. 
    attachObj.Description = "Bug Sample Attachment" 
' Update the attachment record in the project database. 
    attachObj.Post 
' Get the bug attachment extended storage object. 
    Set ExStrg = attachObj.AttachmentStorage 
'Specify the location of the file to upload. 
    ExStrg.ClientPath = "D:\temp\A" 
'----------------------------------------- 
'Use IExtendedStorage.Save to 
' upload the file. 
    ExStrg.Save "SampleAttachment.txt", True 
+0

Yukarıdaki kodunuzu C# olarak denedim, ancak test çalışmasına bir dosya eklenemedi. Bu senin için mi çalıştı? –

1

herkes gereksinimi-modülünde bunu nasıl merak ediyor, burada kodudur? Bueller? Bueller? Bueller?
İlgili konular