Services Object
Description
Enables you to control and monitor how your test runs in conjunction with LoadRunner, or Business Process Monitor. For more details, see the relevant product documentation.
Methods
AddWastedTime | Increments the wasted time for all open transactions. |
EndDistributedTransaction | Marks the end of a distributed transaction and records the amount of time it took to perform the transaction. |
EndTransaction | Marks the end of a transaction and records the amount of time it took to perform the transaction. |
GetEnvironmentAttribute | Retrieves the test's environment properties. |
IterationNumber | Retrieves the current global iteration number of the test execution. |
LogMessage | Sends a log message according to the appropriate level. |
Rendezvous | Sets a rendezvous point in the Vuser script. |
SetTransaction | Reports a completed transaction using manually entered transaction data. |
SetTransactionStatus | Sets the current status for open transactions whose EndTransaction status is set to Auto. |
StartDistributedTransaction | Marks the start of a distributed transaction for performance analysis. |
StartTransaction | Marks the beginning of a transaction for performance analysis. |
ThinkTime | Pauses the execution during a test run to simulate the time a real user pauses between actions. |
UserDataPoint | Records a user-defined data sample for analysis. |
AddWastedTime Method
Description
Increments the wasted time for all open transactions.
Syntax
Services.AddWastedTime (WastedTimeMs)
Argument | Type | Description |
---|---|---|
WastedTimeMs | Integer | The amount of time you want to specify as wasted time for each transaction (in milliseconds). |
IMPORTANT
In transactions, you use the AddWastedTime method to report the time spent performing operations that are not relevant to the actual process you are testing. You can measure the time spent performing the non-related operation using the MercuryTimer Object.
The following example has two Wait statements that are used to simulate time spent performing operations whose performance is measured in a transaction, and one Wait statement that is used to simulate time spent performing a non-related operation that should not be included in the transaction. The time spent performing the non-related operation is measured by the MercuryTimer object. The AddWastedTime method then reports this as wasted time.
Services.StartTransaction "trans1"
Wait 1 ' This simulates operations that we want to measure in the transaction
MercuryTimers("timer1").Start
Wait 1' This simulates a non-related operation for which we want to report time wasted time
Services.AddWastedTime MercuryTimers("timer1").Stop
Wait 1 ' This simulates operations that we want to measure in the transaction
Services.EndTransaction "trans1"
EndDistributedTransaction Method
Description
Marks the end of a distributed transaction and records the amount of time it took to perform the transaction.
Syntax
Services.EndDistributedTransaction UniqueID,Status
Argument | Type | Description |
---|---|---|
UniqueID | String | The unique ID that tells OpenText Functional Testing when to end the distributed transaction measurement. This value must the same as the value used in the same argument in the corresponding StartDistributedTransaction step. The StartDistributedTransaction method looks for this transaction name to know when to end the distributed transaction measurement. Note: Use the naming convention for LoadRunner or Business Availability Center transactions, as relevant. |
Status | Constant | The distributed transaction completion status. Options: Pass (0) Fail (1) Note: The Auto status is not applicable. |
IMPORTANT
You add an EndDistributedTransaction at the point in your test where you want to stop measuring the timing of a task. A distributed transaction enables you to start a transaction in one test and end the same transaction in another test, either within the same Business Process Monitor profile or even in a different profile.
This method is generally used for performance analysis.
Each transaction name should have an associated StartDistributedTransaction and EndDistributedTransaction. The StartDistributedTransaction statement must appear before the associated EndDistributedTransaction. When using two different Business Process Monitor profiles, the profile with the StartDistributedTransaction statement must be run before the profile with the associated EndDistributedTransaction.
Note: There may be cases in which you want to instruct OpenText Functional Testing to perform all the steps in a transaction, even though an error occurs during the run session. In the Run pane of the Test Settings dialog box (File > Settings), select proceed to next step from the When error occurs during run session list.
The EndDistributedTransaction method sends a report that includes the transaction's name, end status, and duration in seconds. If you run the test from LoadRunner or Business Availability Center, you can view the results from the LoadRunner Controller or from Business Availability Center. For details on where to view the results when the test runs from LoadRunner or Business Availability Center, see the relevant product documentation.
Note: If you distribute a transaction across two Business Process Monitor profiles, the run results appear under the profile that contains the StartDistributedTransaction step.
The following example uses the EndDistributedTransaction method to indicate that the distributed transaction named MyDistributedTransaction ended with a status of passed. The distributed transaction is measured across two tests.
Test number 1:
Services.StartDistributedTransaction "MyDistributedTransaction", "A0517165-FF1B-45ae-AA25-29D99B51169E", 10
\\Test Steps Here
Test number 2:
Services.EndDistributedTransaction ,"A0517165-FF1B-45ae-AA25-29D99B51169E", Pass
\\Test Steps Here
EndTransaction Method
Description
Marks the end of a transaction and records the amount of time it took to perform the transaction.
Syntax
Services.EndTransaction Name, [Status]
Argument | Type | Description |
---|---|---|
Name | String | The name of the transaction. Note: Use the naming convention for LoadRunner, Business Availability Center, or NV transactions, as relevant. |
Status | Constant | Optional. A constant (or number) that specifies the ending status of a transaction. If you do not enter a value, Auto is used. Auto (2)—Default. Ends the transaction with a Pass status unless an error occurs between StartTransaction and EndTransaction. Pass (0)—Ends the transaction with a Pass status. Fail (1)—Ends the transaction with a Fail status. |
IMPORTANT
This method is generally used for performance analysis.
During the run session, the StartTransaction step signals the beginning of the time measurement. The time measurement continues until the EndTransaction step is reached. The test results for the EndTransaction step include the transaction's name, end status, total duration, and wasted time.
Wasted time. During a run session, OpenText Functional Testing runs background processes that add to the time it takes to run a test. Wasted time is the time within the total duration that was added as a result of OpenText Functional Testing running the transaction. If the application ran the transaction without OpenText Functional Testing, the total duration would equal the total duration minus the wasted time.
If the test is run from OpenText Functional Testing, you can view the report in the Run Results window. If the test is run from Business Process Monitor or LoadRunner, you can view the results in the relevant location.
Each transaction name should have an associated StartTransaction and EndTransaction. The StartTransaction statement must appear before the associated EndTransaction.
Note: There may be cases in which you want to instruct OpenText Functional Testing to perform all the steps in a transaction, even though an error occurs during the run session. In the Run pane of the Test Settings dialog box (Test > Settings), select proceed to next step from the When error occurs during run session list.
The following example uses the EndTransaction method to indicate that transaction named trans1 ended with a status of passed.
Services.StartTransaction "trans1"
Wait 1
Services.EndTransaction "trans1", Pass
GetEnvironmentAttribute Method
Description
Retrieves the test's environment properties.
Syntax
Services.GetEnvironmentAttribute(Attribute)
Argument | Type | Description |
---|---|---|
Attribute | String | The name attribute you want to retrieve. |
IMPORTANT
This method is generally used only when the test runs in conjunction with LoadRunner. For more details, see the relevant product documentation.
Suppose you enter the following in the command line:
-OrderBook yes -NumOfPayments 24
The following example retrieves values set in the Controller command line and displays them in the log file.
bOrderBook = Services.GetEnvironmentAttribute("OrderBook")
Services.LogMessage (bOrderBook &"OrderBook")
nNumOfPayments = Services.GetEnvironmentAttribute("NumOfPayments")
Services.LogMessage ("NumOfPayments is "& nNumOfPayments)
LogMessage Method
Description
Sends a log message according to the appropriate level, as specified below.
Note: This method is supported only in conjunction with LoadRunner or Business Process Monitor. For more details, see the relevant product documentation.
Syntax
Services.LogMessage Data, [Level]
Argument | Type | Description |
---|---|---|
Data | String | The message data. |
Level | Long | Optional. Use one of the following constants or numbers to specify the message status and where it should be sent:
If you do not specify a level, the message is treated as OutputMsg. |
In the following example, the message sets the test status to fail, and appears as an error message.
Services.LogMessage "An error occurred", ErrorMsg
Rendezvous Method
Description
Sets a rendezvous point in the Vuser script.
Note: This method is supported only when the test runs in conjunction with LoadRunner or Business Process Monitor. For more details, see the specific product documentation.
Syntax
Services.Rendezvous Name
Argument | Type | Description |
---|---|---|
Name | String | The name of the rendezvous to be inserted in the script. |
SetTransaction Method
Description
Reports a completed transaction using manually entered transaction data.
Syntax
Services.SetTransaction Name, DurationSec, Status
Argument | Type | Description |
---|---|---|
Name | String | The name of the transaction. Note: Use the naming convention for LoadRunner or Business Availability Center transactions, as relevant. |
DurationSec | Decimal | The transaction duration in seconds. |
Status | Constant | The transaction completion status. Options: Pass (0) Fail (1) Note: The Auto status is not applicable. |
IMPORTANT
This method sends a report that includes the transaction's name, end status, and duration in seconds. If the test is run from OpenText Functional Testing, you can view the report in the Run Results window. If the test is run from Business Process Monitor or LoadRunner, you can view the results in the relevant location.
This method is generally used only in conjunction with LoadRunner or Business Process Monitor. For more details, see the relevant product documentation.
The following example measures time using the MercuryTimers object, Timer1. Then, it sends a report to the Run Results window specifying the elapsed time. It converts the reported time from milliseconds to seconds. Finally, it uses the SetTransaction method to report that the Timer1 transaction completed with a Pass status and a duration of 10 seconds.
MercuryTimers("Timer1").Start 'Start measuring time using Timer1.
Wait 10
MercuryTimers("Timer1").Stop 'After ten seconds, stop Timer1.
'Send a report to the run results specifying the elapsed time for the timer object
'(Timer1 ~10000 ms).
Reporter.ReportEvent micDone, "Elapsed Time", "Timer1: " & MercuryTimers("Timer1").Stop() & "ms"
'Set a transaction manually for the timer object. Convert the elapsed time for the
'timer object from milliseconds to seconds so the elapsed time will be reported
'correctly in the transaction.
Services.SetTransaction "Timer1",MercuryTimers("Timer1").ElapsedTime / 1000,Pass
SetTransactionStatus Method
Description
Sets the current status for open transactions whose EndTransaction status is set to Auto.
Syntax
Services.SetTransactionStatus Status
Argument | Type | Description |
---|---|---|
Status | Constant | The current status of a transaction. Available options: Pass (0) Fail (1) |
IMPORTANT
The SetTransactionStatus statement overrides the status of any previous steps in open transactions, including previous SetTransactionStatus statements.
This method is generally used only in conjunction with LoadRunner or Business Process Monitor. For more details, see the relevant product documentation.
The following example sets the status for trans1 to Fail. Even though the SetTransactionStatus statement is included in the trans2 transaction, it does not affect its end status because the trans2 transaction does not specify Auto for its EndTransaction statement.
Services.StartTransaction "trans1" Services.StartTransaction "trans2"
Services.SetTransactionStatus Fail
Services.EndTransaction "trans2", Pass Services.EndTransaction "trans1", Auto
StartDistributedTransaction Method
Description
Marks the start of a distributed transaction for performance analysis.
Syntax
Services.StartDistributedTransaction TransactionName, UniqueID, Timeout
Argument | Type | Description |
---|---|---|
TransactionName | String | The name of the distributed transaction. Note: Use the naming convention for LoadRunner or Business Availability Center transactions, as relevant. |
UniqueID | String | The unique ID that tells OpenText Functional Testing when to end the distributed transaction measurement. This value must be unique across all tests and profiles. We recommend that you use a tool to generate a GUID (globally unique identifier). The same unique ID must also be specified in the same argument of the corresponding EndDistributedTransaction step. |
Timeout | Integer | The number of seconds to wait before ending the transaction, if the specified EndDistributedTransaction step is not reached. Note: When using two Business Process Monitor profiles, make sure that the timeout value is large enough so that the profile that contains the StartDistributedTransaction step and all the profiles that run before the profile that contains the EndDistributedTransaction step, will finish running in a time that is less than the value of the specified timeout. |
IMPORTANT
You add a StartDistributedTransaction at the point in your test where you want to begin measuring the timing of a task. A distributed transaction enables you to start a transaction in one test and end the same transaction in another test, either within the same Business Process Monitor profile or even in a different profile.
Each transaction name should have an associated StartDistributedTransaction and EndDistributedTransaction. When using two different Business Process Monitor profiles, the profile with the StartDistributedTransaction statement must be run before the profile with the associated EndDistributedTransaction.
Make sure that you relate the tests to a single Business Process Monitor instance. Business Process Monitor searches for the end transaction name in all instances, and may close the wrong distributed transaction if it is included in more than one instance.
If you run the test from LoadRunner or Business Availability Center, you can view the results from the LoadRunner Controller or from Business Availability Center. For details on where to view the results when the test runs from LoadRunner or Business Availability Center, see the relevant product documentation.
Note: If you distribute a transaction across two Business Process Monitor profiles, the run results appear under the profile that contains the StartDistributedTransaction step.
The following example uses the StartDistributedTransaction method to measure the distributed transaction named MyDistributedTransaction across two tests.
Test number 1:
Services.StartDistributedTransaction "MyDistributedTransaction", "A0517165-FF1B-45ae-AA25-29D99B51169E", 10
\\Test Steps Here
Test number 2:
Services.EndDistributedTransaction ,"A0517165-FF1B-45ae-AA25-29D99B51169E", Pass
\\Test Steps Here
StartTransaction Method
Description
Marks the beginning of a transaction for performance analysis.
Syntax
Services.StartTransaction Name
Argument | Type | Description |
---|---|---|
Name | String | The name of the transaction. Note: Use the naming convention for LoadRunner, Business Availability Center, or NV transactions, as relevant. |
IMPORTANT
You add a StartTransaction at the point in your test where you want to begin measuring the timing of a task.
Each transaction name should have an associated StartTransaction and EndTransaction. The StartTransaction statement must appear before the associated EndTransaction.
If you run the test from OpenText Functional Testing, you can view the results in the Run Results window. If you run the test from LoadRunner or Business Availability Center, you can view the results from the LoadRunner Controller or from Business Availability Center. For details on where to view the results when the test runs from LoadRunner or Business Availability Center, see the relevant product documentation.
The following example uses StartTransaction method to open a transaction called trans1, wait 4 seconds, and then close the transaction.
Services.StartTransaction "trans1"
Wait 4
Services.EndTransaction "trans1"
ThinkTime Method
Description
Pauses the execution during a test run to simulate the time a real user pauses between actions.
Syntax
Services.ThinkTime Seconds
Argument | Type | Description |
---|---|---|
Seconds | Integer | The number of seconds to pause the test during execution. |
IMPORTANT
This method is generally used only in conjunction with LoadRunner or Business Process Monitor. For more details, see the relevant product documentation.
UserDataPoint Method
Description
Records a user-defined data sample for analysis.
Note: This method is supported only in conjunction with LoadRunner or Business Process Monitor. For more details, see the specific product documentation.
Syntax
Services.UserDataPoint Value, Name
Argument | Type | Description |
---|---|---|
Value | Double | The value to record. |
Name | String | The label of the data point as it appears on the graph. |
The following statement gathers the price of a product each time the test executes the step and puts the price in the data table column labeled "Price_P". After the test executes the step numerous times (for example, in a loop), the data points appear on a graph where the price is labeled "Price."
Services.UserDataPoint DataTable("Price_P"), "Price"
See also:
- Crypt Object
- DataTable Object
- Description Object
- DeviceReplay Object
- DotNetFactory Object
- DTParameter Object
- DTSheet Object
- Environment Object
- Extern Object
- Parameter Object
- JSON Object
- JsonUtil Object
- MercuryTimers Object (Collection)
- MercuryTimer Object
- NV Object
- OptionalStep Object
- ParallelUtil Object
- LocalParameter Object
- PasswordUtil Object
- PathFinder Object
- PDFUtil Object
- Properties Object (Collection)
- QCUtil Object
- RandomNumber Object
- Recovery Object
- Remote Connection Object
- Reporter Object
- RepositoriesCollection Object
- Repository Object
- Services Object
- Setting Object
- SystemMonitor Object
- TestArgs Object
- TextUtil Object
- UIAutomation Object
- VisualRelation Object
- VisualRelations Object
- VisualRelationsCollection Object
- WebUtil Object
- XMLUtil Object