使用OTA和JACOB在ALM中创建测试脚本时出现的问题

时间:2012-07-16 08:44:34

标签: vbscript hp-quality-center jacob qc

我在vbscript中创建了一段代码,通过它我可以通过OTA在ALM中创建测试脚本。 现在我试图通过Java使用JACOB作为Java 2 Com桥来做同样的事情,我已经能够使用它创建一个空的测试脚本,但我不知道如何设置各种字段值。

VBScript代码(完美无缺):

           Set tdc = CreateObject("TDAPIOLE80.TDConnection")
           If (tdc Is Nothing) Then
             MSGBOX "Connection is not created"
           Else
            MSGBOX "Connection is created"
           End If
           tdc.InitConnectionEx connectionString
           tdc.Login userName, password
           tdc.Connect domain, project
           Set TreeMgr = tdc.TreeManager
           Set testFolder = TreeMgr.NodeByPath(uploadDirectoryPath)
           Set testFactory = testFolder.TestFactory
           Set testItem = testFactory.AddItem (NULL)
           testItem.Field("TS_DESCRIPTION")="Test script description"
           ...

Java代码(只有那么多有用)

     ActiveXComponent almConnection=new ActiveXComponent("TDAPIOLE80.TDConnection");
    Dispatch.call(almConnection, "InitConnectionEx", "conn string");        
    Dispatch.call(almConnection, "login", "uname","pword");
    Dispatch.call(almConnection, "connect","project","domain");     
    Dispatch treeMgr=Dispatch.get(almConnection, "TreeManager").toDispatch();
    Dispatch testFolder=Dispatch.call(treeMgr,"NodeByPath", "project path").toDispatch();
    Dispatch testFactory=Dispatch.get(testFolder, "TestFactory").toDispatch();              
    Dispatch testItem=Dispatch.call(testFactory,"AddItem","TO_BE_DELETED_SCRIPT9").toDispatch();

现在问题是VBScript代码中的最后一行,

            testItem.Field("TS_DESCRIPTION")="Test script description"

如何使用JACOB在Java中编写代码? 请帮忙。我做了很多谷歌搜索,但没有发现任何实质性的内容。

1 个答案:

答案 0 :(得分:2)

这对我有用:

Dispatch testItem=Dispatch.call(testFactory,"AddItem","TestName").toDispatch();
Dispatch.put(testItem, "Name", "newTestName");
Dispatch.call(testItem,"Post");

如何使用JACOB更改HPQC中的字段值:

http://sourceforge.net/projects/jacob-project/forums/forum/375946/topic/4830213