A custom attribute called VirtualUser can be applied to classes. This attribute instructs the Add-In’s BDL generation engine to generate a virtual user definition. You can implement multiple classes that have the VirtualUser attribute applied to them. The VirtualUser attribute takes the name virtual user as a parameter.
The BDL generation engine parses the methods of the VirtualUser class for methods that have a Transaction attribute applied to them. The Transaction attribute takes the transaction type, Init, Main or End, as a first parameter. You can only have one Init and one End transaction, but multiple Main transactions are allowed.
The Main transaction type takes a second parameter that indicates the number of times that the transaction is to be called during a test (the default is 1).
Following are the available custom attributes and what the BDL generation engine scripts for them.
Attribute Class | Applicable to | Parameters | Description |
---|---|---|---|
VirtualUser | Class | Name of the Virtual User Group
(optional) IsUnitTest |
Defines a Virtual User Group.
If you specify true, DotNetUnitTest methods will be scripted instead of the standard DotNet methods (e.g., DotNetUnitTestLoadObject). |
Transaction | Method | Type (Init, Main, End)
If type is Main the number of transaction iterations (optional) Name |
Defines a Transaction for the Virtual User Group.
The transaction implementation will call the method of the .NET Object. The first script call in the Init transaction is a DotNetLoadObject loading the Object The last script call in the end transaction is a DotNetFreeObject. Optionally you can define a name that should be used in the generated BDL script for this transaction. By default, the transaction name in BDL is created by combining the VUser name and the method name. |
TestMethod | Method | This will script a call to the method in the current transaction.
The current transaction is the previous method with a Transaction attribute. So a method with this attribute that has no prior method with a Transaction attribute makes no sense. |
|
TestAttribute | Method | Attribute Name
Attribute Value (optional) Description |
This can be applied multiple times to a method that has either a Transaction or TestMethod attribute.
An AttributeSetString function will be scripted prior to the DotNetCallMethod that calls this method. AttributeSetString will set an attribute with the passed name and value. This is a way how parameters can be passed from the script to the .NET function. The .NET function can read the attributes with Bdl.AttributeGet. Its meant that people (QA) who will receive the finished script only have to change the value passed to the AttributeSetString to customize the script. So there is no need for them to change the .NET Code. Allows you to define a description for the project attribute. The description can be seen in Silk Performer's project attribute wizard. |
VirtualUserInitialize | Method | This method is called for classes that are loaded via DotNetUnitTestLoadObject | |
VirtualUserCleanup | Method | This method is called for classes that are freed via DotNetUnitTestFreeObject | |
TestCleanup | Method | This method is called after a method is called via DotNetUnitTestCallMethod | |
TestInitialize | Method | This method is called before a method is called via DotNetUnitTestCallMethod | |
TestIgnore | Method | Methods that have this attribute applied to them will not be called via DotNetUnitTestCallMethod | |
TestException | Method | Type of exception
Additional log message |
Normally, methods that throw exceptions are considered failed. If you want a method to throw an exception, you can use the TestException attribute to tell Silk Performer that this method is supposed to throw an exception. |