New and Improved Test Composer, Part II: Custom Op...
Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
[Last week | New and Improved Test Composer, Part I], we were talking about the latest version of the SAP Business One Test Composer (B1TC), the tool for setting up test automation for your add-ons. B1TC lets you record actions in SAP Business One and create a script, which you can later rerun to check if your add-on is working properly. This week, I want to show you how to create custom operations for B1TC. Much of what I write about I also explain in a short {code:html}video{code}. h3. Out-of-the-Box Operations B1TC lets you record B1 actions, and creates a script from the recording. Each line in the script is a different operation. For example, a line can simulate clicking on a button, opening a form, or selecting a menu item in the SAP Business One application. Within a script, you can double-click on a line and the Edit window is displayed. The Operation dropdown box, to the left, shows you all the existing operations.You can create your own operation, for example, to create a backup of a DB2 database since B1TC has an operation for backing up a SQL Server database only. h3. How to Create Extension There are basically three steps in the process: * Register the DLL with B1TC. * Add the operation to a script. h4. Create DLL Create the code to be executed whenever the custom operation is added to a script. 1. Create a class library using Microsoft Visual Studio. 2. Create a method for each custom operation. This method is called whenever a running script executes a line with the custom operation. The method must have the following signature (you can name the method as you like): public static void methodName (System.Collections.ArrayList arr) { } When the custom operation is added to a script, string parameters can also be specified. These strings are passed to the method in the ArrayList parameter. 3. Build the project to create a DLL. h4. Register DLL Let B1TC know about your DLL, and specify a name for the custom operation and the method to call when the operation is executed. 1. In the main menu, select +Tools+ --> +Settings+.0.1. In the +Advanced+ pane, click +Register External DLL+. The following is displayed: 0.1. Under +DLL List+, click +Add+ and select the DLL that contain the functions that define the operations. A reference to the DLL is added to the +References+ tree. 0.1. Register operations. For each operation, do the following: 1. Under +Function List+, click +Add+.0.1. Enter the name of the function to be executed for this operation, and then click +OK+. Enter an operation name, and click +OK+. 0.1. Click +OK+. h4. Add Operation Now add the operation to a script. 1. In the script editor, right-click the line where you want to insert a custom operation, and select +Insert+* --> *+External Function+.0.1. From the +Operation+ dropdown box, select a custom operation.0.1. Add parameters for the operation, if needed.