使用 QC 集成工具并在测试计划中创建测试时遇到问题 - 不幸的是,API 是为 VB6 编写的,而我正在使用 C#。
这是我到目前为止所得到的:
private void HPQC_Create_Test_Plan_Test(TDConnectionClass tdConnection, string ParentFolderPath, string TestName)
{
try
{
TreeManager treeM = (TreeManager)tdConnection.TreeManager;
ISysTreeNode ParentFolder = (ISysTreeNode)treeM.get_NodeByPath(ParentFolderPath);
TestFactory TestF = (TestFactory)tdConnection.TestFactory;
Test TstTest = (Test)TestF.AddItem(System.DBNull.Value);
TstTest.Name = TestName;
TstTest.Type = "MANUAL";
TstTest.Post();
HPQC_Status_Test_Plan.Text = "Test " + TestName + " created.";
tdConnection.Logout();
tdConnection.Disconnect();
tdConnection = null;
}
catch (Exception ex)
{
HPQC_Status_Test_Plan.Text = "Test Creation Failed.";
Console.WriteLine("[Error] " + ex);
tdConnection.Logout();
tdConnection.Disconnect();
tdConnection = null;
}
}
帖子上的代码错误只是一个简单的“无法发布”,我不知道为什么。
这是 VB6 中的 API 示例:
Public Sub AddTest(FolderName$, TestName$)
创建新的测试。此示例假定包含新测试的主题文件夹直接位于根“主题”文件夹下。
Dim objTest As Test
Dim folder As SubjectNode
Dim testF As TestFactory
Dim TreeMgr As TreeManager
Dim Path As String
Dim Trees As List
Dim RootName As String
Dim SubjRoot As SubjectNode
'tdc is the global TDConnection object.
Set TreeMgr = tdc.TreeManager
' Use TreeManager.TreeRoot to get the list of subject
' root nodes from the tree manager.
' There is only one item in this list.
Set Trees = TreeMgr.RootList(TDOLE_SUBJECT)
' Get the name of the subject tree root in your project.
RootName = Trees.Item(1)
Path = RootName & "\" & FolderName
On Error Resume Next
Set folder = TreeMgr.NodeByPath(Path)
On Error GoTo 0
If folder Is Nothing Then 'Create the folder
' Get the SubjectNode root node object from the
' tree manager by name.
Set SubjRoot = TreeMgr.TreeRoot(RootName)
Set folder = SubjRoot.AddNode(FolderName)
End If
Set testF = folder.TestFactory
Set objTest = testF.AddItem(Null)
objTest.name = TestName
objTest.Type = "SYSTEM-TEST"
objTest.Post
Dim VerCtl As VCS
Dim bIsLocked As Boolean
Dim strLockedBy As String
Set VerCtl = objTest.VCS
VerCtl.Refresh
bIsLocked = VerCtl.IsLocked
strLockedBy = VerCtl.LockedBy
' After POST, Test is checked in.
Debug.Print "Is locked: " & bIsLocked
'Is locked: False
Debug.Print "Is locked by: """ & strLockedBy & """"
'Is locked by: ""
VerCtl.CheckOut -1, "To change state", True
VerCtl.Refresh
bIsLocked = VerCtl.IsLocked
strLockedBy = VerCtl.LockedBy
Debug.Print "Is locked: " & bIsLocked
'Is locked: True
Debug.Print "Is locked by: """ & strLockedBy & """"
'Is locked by: "User1"
' Take an arbitrary field to change.
Debug.Print "Status: """ & objTest.Field("TS_STATUS") & """"
'Status: ""
objTest.Field("TS_STATUS") = "Ready"
objTest.Post
VerCtl.CheckIn "", "Changed status"
VerCtl.Refresh
bIsLocked = VerCtl.IsLocked
strLockedBy = VerCtl.LockedBy
Debug.Print "Is locked: " & bIsLocked
'Is locked: False
Debug.Print "Is locked by: """ & strLockedBy & """"
'Is locked by: ""
结束子
提前致谢!