IsInit Property

Applies to TestComplete 14.71, last modified on April 22, 2021

The object-driven testing (ODT) functionality is deprecated. Do not use it to create new tests. It will be removed from the product in one of the future releases. As an alternative, you can create custom classes in your scripts. For more information, see Alternatives to the ODT functionality.

Description

The IsInit property specifies whether the object’s method is an “Init” method. The “Init” attribute is used by the Run methods when they walk down the object hierarchy. If the method is specified as “Init” , TestComplete runs it before analyzing the properties of the object to which the method belongs. For more information, see Controlling Object-Driven Tests. If you set IsInit to True, TestComplete will reset the Enabled property to False.

Declaration

MethodObj.IsInit

Read-Write Property Boolean
MethodObj An expression, variable or parameter that specifies a reference to a Method object

Applies To

The property is applied to the following object:

Property Value

If IsInit is True, the method becomes an “Init’ method.

Example

The following example creates an object based on the declared NewClass class, obtains the method that belongs to the object and specifies that the obtained method is an “Init” method.

JavaScript, JScript

function MethodSample()
{
  var NewClass, NewObj, MethodObj;
  // Deletes all the existing classes and variables
  ODT.Data.Clear();
  ODT.Classes.Clear();

  // Declares a new class
  NewClass = ODT.Classes.Declare("NewClass");
  // Declares a new class method
  NewClass.AddMethod("NewClassMethod", "Unit1.Test1");
  // Creates an object
  NewObj = ODT.Classes.New("NewClass");
  // Obtains the object’s method by its index
  MethodObj = NewObj.Methods(0);
  // Specifies that the method is an "Init" method
  MethodObj.IsInit = true;
  …

}

VBScript

Sub MethodSample

  ' Deletes all the existing classes and variables
  ODT.Data.Clear
  ODT.Classes.Clear

  ' Declares a new class
  Set NewClass = ODT.Classes.Declare("NewClass")
  ' Declares a new class method
  Call NewClass.AddMethod("NewClassMethod", "Unit1.Test1")
  ' Creates an object
  Set NewObj = ODT.Classes.New("NewClass")
  ' Obtains the object’s method by its index
  Set MethodObj = NewObj.Methods(0)
  ' Specifies that the method is an "Init" method
  MethodObj.IsInit = true
  …

End Sub

DelphiScript

procedure MethodSample();
var NewClass, NewObj, MethodObj;
begin
  // Deletes all the existing classes and variables
  ODT.Data.Clear;
  ODT.Classes.Clear;

  // Declares a new class
  NewClass := ODT.Classes.Declare('NewClass');
  // Declares a new class method
  NewClass.AddMethod('NewClassMethod', 'Unit1.Test1');
  // Creates an object
  NewObj := ODT.Classes.New('NewClass');
  // Obtains the object’s method by its index
  MethodObj := NewObj.Methods(0);
  // Specifies that the method is an "Init" method
  MethodObj.IsInit := true;
  …

end;

C++Script, C#Script

function MethodSample()
{
  var NewClass, NewObj, MethodObj;
  // Deletes all the existing classes and variables
  ODT["Data"]["Clear"]();
  ODT.Classes.Clear();

  // Declares a new class
  NewClass = ODT["Classes"]["Declare"]("NewClass");
  // Declares a new class method
  NewClass["AddMethod"]("NewClassMethod", "Unit1.Test1");
  // Creates an object
  NewObj = ODT["Classes"]["New"]("NewClass");
  // Obtains the object’s method by its index
  MethodObj = NewObj["Methods"](0);
  // Specifies that the method is an "Init" method
  MethodObj["IsInit"] = true;
  …

}

See Also

Controlling Object-Driven Tests
Enabled Property

Highlight search results