简体   繁体   中英

How to Capture data, store data, perform math operations and verify data in IBM Mobilefirst TestWorkbench 8.6.0.1

Tool: IBM Mobilefirst TestWorkbench 8.6.0.1
OS: Windows 7

Have an app which displays 3 text boxes, two to input numbers and a third displays the sum of numbers
Record a test. (Enter number in each of the two text box; the result is displayed in the third test box)

While playback, is it possible to store the numbers in variables, add them and cross-verify with result that the app displays ?

The above would help us to verify transactions in banking applications

yes, it is possible

  • First, create a variable in your script (open 'Text Resources' node, right click on 'Test Variables' and choose 'Add' menu
  • Then, in the mobile data view, right-click on the element that contain the number, and choose 'Create a variable assignment from Text' and assign the value to the variable you have just created before
  • Do the same for the second variable
  • Then at the point of the script where you want to do the sum, just add a custom code splitting first the script (menu 'Split Mobile or Web UI actions..') and insert a custom code (menu 'Insert > Custom Code' on the 'In application' node that you have just created)
  • Add the 2 variables as parameters of the custom code and implement the sum

You can find custom code examples here http://www-01.ibm.com/support/knowledgecenter/SSBLQQ_8.7.0/com.ibm.rational.test.lt.common.doc/topics/textndteswcc.html?cp=SSBLQQ_8.7.0%2F0-6-11-0&lang=en

Dominique

Find below Custon Code i have used for doing the operation i mentioned in the question(Edited a bit)

In "Custom Code Details" Add arguments. args[0] in code refers to the first argument added in "Custom Code Details".

package customcode;
import org.eclipse.hyades.test.common.event.VerdictEvent;
import com.ibm.rational.test.lt.kernel.services.ITestExecutionServices;

/**
 * @author unknown
 */
public class Class implements
        com.ibm.rational.test.lt.kernel.custom.ICustomCode2 {

    /**
     * Instances of this will be created using the no-arg constructor.
     */
    public Class() {
    }

    /**
     * For javadoc of ICustomCode2 and ITestExecutionServices interfaces, select 'Help Contents' in the
     * Help menu and select 'Extending Rational Performance Tester functionality' -> 'Extending test execution with custom code'
     */
    public String exec(ITestExecutionServices tes, String[] args) {

        String L4_InitBalance = args[1];
        String L1_InitBalance = args[0];

        String L4_FinalBalance = args[3];
        String L1_FinalBalance = args[2];



        if((L4_InitBalance == L4_FinalBalanc)&&(L1_InitBalance == L1_FinalBalance))
            tes.getTestLogManager().reportVerificationPoint("SFT PASSED",VerdictEvent.VERDICT_PASS,"SFT has PASSED");
        else
            tes.getTestLogManager().reportVerificationPoint("SFT FAILED",VerdictEvent.VERDICT_FAIL,"SFT has FAILED");

        return null;
    }

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM