Description
The ProjectTests_COMAccess
object provides a program interface for a project’s or a project suite’s test items collection. It contains properties that let you work with individual test items. To obtain the ProjectTests_COMAccess
object, connect to TestComplete via COM and use the TestSuite
property of the TestComplete Integration
object or the Project
property of the ProjectSuiteTestItem_COMAccess
object. For more information, see Working With TestComplete via COM - Overview.
Members
Example
The following example demonstrates how you can obtain the ProjectTests_COMAccess
object.
Visual Basic
…
Dim TestCompleteApp As TestCompleteApplication
Dim IntegrationObject As ItcIntegration
Dim LastResult As ItcIntegrationResultDescription
' Creates the application object
Set TestCompleteApp = CreateObject("TestComplete.TestCompleteApplication.14")
' Obtains the integration object
Set IntegrationObject = TestCompleteApp.Integration
' Opens the project suite
IntegrationObject.OpenProjectSuite "C:\Work Folder\TestSuite\TestSuite.pjs"
' To obtain the ProjectTests_COMAccess object
' That provides a program interface to the project’s test item collection
' Use the following code
Set ProjectItems = IntegrationObject.TestSuite("TestProject")
' or
Set ProjectItems = IntegrationObject.TestSuite("").TestItem(0).Project
…
Dim TestCompleteApp As TestCompleteApplication
Dim IntegrationObject As ItcIntegration
Dim LastResult As ItcIntegrationResultDescription
' Creates the application object
Set TestCompleteApp = CreateObject("TestComplete.TestCompleteApplication.14")
' Obtains the integration object
Set IntegrationObject = TestCompleteApp.Integration
' Opens the project suite
IntegrationObject.OpenProjectSuite "C:\Work Folder\TestSuite\TestSuite.pjs"
' To obtain the ProjectTests_COMAccess object
' That provides a program interface to the project’s test item collection
' Use the following code
Set ProjectItems = IntegrationObject.TestSuite("TestProject")
' or
Set ProjectItems = IntegrationObject.TestSuite("").TestItem(0).Project
…
C#
…
const string TCProgID = "TestComplete.TestCompleteApplication.14";
object TestCompleteObject = null;
// Obtains access to TestComplete
try
{
TestCompleteObject = Marshal.GetActiveObject(TCProgID);
}
catch
{
try
{
TestCompleteObject = Activator.CreateInstance(Type.GetTypeFromProgID(TCProgID));
}
catch
{
}
}
// Obtains ITestCompleteCOMManager
TestComplete.ITestCompleteCOMManager TestCompleteManager = (TestComplete.ITestCompleteCOMManager) TestCompleteObject;
// Obtains the Integration object
TestComplete.ItcIntegration IntegrationObject = TestCompleteManager.Integration;
// Loads the project suite
IntegrationObject.OpenProjectSuite("C:\\Work Folder\\TestSuite\\TestSuite.pjs");
// To obtain the ProjectTests_COMAccess object providing a program interface to the project’s test item collection
// Use the following code:
object ObjProjectItems = IntegrationObject.get_TestSuite("TestProject");
TestComplete.ItcProjectTests_COMAccess ProjectItems = (TestComplete.ItcProjectTests_COMAccess)ObjProjectItems;
// or
object PSTestItem = IntegrationObject.get_TestSuite("");
TestComplete.ItcProjectSuiteTests_COMAccess NewPSTestItems = (TestComplete.ItcProjectSuiteTests_COMAccess)PSTestItem;
TestComplete.ItcProjectTests_COMAccess ProjectItems = NewPSTestItems.get_TestItem(0).Project;
…
const string TCProgID = "TestComplete.TestCompleteApplication.14";
object TestCompleteObject = null;
// Obtains access to TestComplete
try
{
TestCompleteObject = Marshal.GetActiveObject(TCProgID);
}
catch
{
try
{
TestCompleteObject = Activator.CreateInstance(Type.GetTypeFromProgID(TCProgID));
}
catch
{
}
}
// Obtains ITestCompleteCOMManager
TestComplete.ITestCompleteCOMManager TestCompleteManager = (TestComplete.ITestCompleteCOMManager) TestCompleteObject;
// Obtains the Integration object
TestComplete.ItcIntegration IntegrationObject = TestCompleteManager.Integration;
// Loads the project suite
IntegrationObject.OpenProjectSuite("C:\\Work Folder\\TestSuite\\TestSuite.pjs");
// To obtain the ProjectTests_COMAccess object providing a program interface to the project’s test item collection
// Use the following code:
object ObjProjectItems = IntegrationObject.get_TestSuite("TestProject");
TestComplete.ItcProjectTests_COMAccess ProjectItems = (TestComplete.ItcProjectTests_COMAccess)ObjProjectItems;
// or
object PSTestItem = IntegrationObject.get_TestSuite("");
TestComplete.ItcProjectSuiteTests_COMAccess NewPSTestItems = (TestComplete.ItcProjectSuiteTests_COMAccess)PSTestItem;
TestComplete.ItcProjectTests_COMAccess ProjectItems = NewPSTestItems.get_TestItem(0).Project;
…
See Also
TestSuite Property
Project Property
Working With TestComplete via COM - Overview
Tests and Test Items