Highlighted
Valued Contributor.. imi_qn Valued Contributor..
Valued Contributor..
1048 views

TestFactory.AddItem not works

Jump to solution

Hi there,

I'm struggling with the code below since hours. Can somebody help me what am I doing wrong? The goal is to create a new test case within the workflow.  

Function AddNewTestCase
Dim TestObj
Dim TestFactory

Set tdc = TDConnection.TestFactory
Set TestObj = TestFactory.AddItem (null)

TestObj.SubjectID = 1154               '=Subject/Temp folder
TestObj.Name = "iva_test_01"
TestObj.Tester = "iva"
TestObj.Type = "MANUAL"
TestObj.Post

Set tdc = Nothing
Set TestObj = Nothing
End Function

Thanks in advance.

 

0 Likes
1 Solution

Accepted Solutions
cmt8455 Absent Member.
Absent Member.

Re: TestFactory.AddItem not works

Jump to solution

Hi imi_qn. I should have been more specific. I was referring to the properties of the Test Object/TestObj. Since the tester is assigned in the Test Lab, I would think that you wouldn't be able to use .Tester with the Test Object, but I could be wrong. I usually add tests using the Excel add-in. The OTA reference should answer this question. Are you running the code with the error handling statements commented out?

I wrote this just now & it works for me:

Sub MyTest()

    Dim TDConnection
    Set TDConnection = CreateObject("tdapiole80.tdconnection")    
    TDConnection.InitConnectionEx "<URL>"
    TDConnection.Login "<username>", "<password>"     
    TDConnection.Connect "<domain>", "<project>"


    Set testF = TDConnection.TestFactory
    Set testObj = testF.AddItem(Null)
    testObj.Name = "Test1"
    testObj.Type = "MANUAL"
    testObj.Field("TS_SUBJECT") = "MyFolder"
    testObj.Post

    
  TDConnection.Disconnect
  TDConnection.ReleaseConnection
  Set TDConnection = Nothing
End Sub

7 Replies
Absent Member.. Trudy Claspill Absent Member..
Absent Member..

Re: TestFactory.AddItem not works

Jump to solution

Are you getting any error messages? If so, what are they?

[If this post solves or helps solve your issue, mark the thread as solved and give KUDOS to the author for their assistance.]

(Opinions expressed in my postings are mine alone, and do not reflect the opinions of my employer.No warranties express or implied for any solution/suggestion posted.)
0 Likes
Valued Contributor.. imi_qn Valued Contributor..
Valued Contributor..

Re: TestFactory.AddItem not works

Jump to solution

Nope. Nothing is happening upon calling the function. 

0 Likes
cmt8455 Absent Member.
Absent Member.

Re: TestFactory.AddItem not works

Jump to solution

Hi imi_qn. Did you verify your property names? Try FolderId instead of SubjectID. Also there may not be a Tester property.

0 Likes
Valued Contributor.. imi_qn Valued Contributor..
Valued Contributor..

Re: TestFactory.AddItem not works

Jump to solution

Hi cmt8455,

thanks for trying to help me.

Yes, this was the first thing I've to check the method, this says:

Public Function AddItem( _
   ByVal Itemdata As Variant _
) As Object
Parameters
ItemData

There are three options for ItemData:

  • Null. Initially creating a virtual Test object with Null ensures that you cannot then Post until all required fields are initialized.
  • The test name.
  • An array consisting of the following elements:
  • (0) Name - The test name (required).
  • (1) Type - The test type (string, optional). The possible test types are detailed in the table below.
  • (2) Tester - The name of the user that created the test (string, optional). The default value is the name of the user currently logged in (string, optional).
  • (3) SubjectID - The ID of the subject folder in which to create the test (long, optional).

I've also tried to change the code with FolderID (code below), but it doesn't helped anything.  Simply happens nothing when I call the function, no error messages were shown.  How am I able to debug this code? What am I doing wrong?

Function Generate_1
  On Error Resume Next
     Dim TestObj
     Dim TestFactory

     Set tdc = TDConnection.TestFactory
     Set TestObj = TestFactory.AddItem(null)

     TestObj.FolderID = 1154
     TestObj.Name = "iva_test_01"
     TestObj.Type = "MANUAL"
     TestObj.Post

     Set tdc = Nothing
     Set TestObj = Nothing
  On Error GoTo 0
End Function

 

0 Likes
cmt8455 Absent Member.
Absent Member.

Re: TestFactory.AddItem not works

Jump to solution

Hi imi_qn. I should have been more specific. I was referring to the properties of the Test Object/TestObj. Since the tester is assigned in the Test Lab, I would think that you wouldn't be able to use .Tester with the Test Object, but I could be wrong. I usually add tests using the Excel add-in. The OTA reference should answer this question. Are you running the code with the error handling statements commented out?

I wrote this just now & it works for me:

Sub MyTest()

    Dim TDConnection
    Set TDConnection = CreateObject("tdapiole80.tdconnection")    
    TDConnection.InitConnectionEx "<URL>"
    TDConnection.Login "<username>", "<password>"     
    TDConnection.Connect "<domain>", "<project>"


    Set testF = TDConnection.TestFactory
    Set testObj = testF.AddItem(Null)
    testObj.Name = "Test1"
    testObj.Type = "MANUAL"
    testObj.Field("TS_SUBJECT") = "MyFolder"
    testObj.Post

    
  TDConnection.Disconnect
  TDConnection.ReleaseConnection
  Set TDConnection = Nothing
End Sub

Valued Contributor.. imi_qn Valued Contributor..
Valued Contributor..

Re: TestFactory.AddItem not works

Jump to solution

Hi cmt8455,

many thanks for the code below. It's worked perfectly. I can use this code to getting further. I really appreciatate your help...

0 Likes
cmt8455 Absent Member.
Absent Member.

Re: TestFactory.AddItem not works

Jump to solution

You're welcome. I'm glad that it worked for you.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.