TestOptimal Tutorials

MScript Introduction

MScript Introduction

This tutorial will cover:

  • What is MScript
  • MScript Triggers
  • MScript Tags
  • MScript Variables
  • MScript Functions

MScript Intro - What's MScript

  • Scripting Language by TestOptimal
  • XML-based Tags
    <action code="$click('[btnId]')"/>
    <log msg="Clicked on element identified by user variable 'btnId'."/>
  • Consists of:
    • MScript Tags
    • MScript Functions
    • User/System Variables

press down arrow for feature details

MScript Intro - What's MScript

MScript is Placed in MScript Triggers to:

  • Output Test Cases
  • Perform Test Automation
  • Perform Test Validation (Test Oracle)

press down arrow for feature details

MScript Intro - What's MScript

Example MScript:


<action code="$setVar('itemCountExpected', '[ShoppingCartItemCount]')"/>
<action code="$increment('itemCountExpected')"/>
<action code="$setVar('addProdCode', '$randFromList('IPad|PicFrame|UsbMem')')"/>
<action code="$click('css=#[addProdCode] .addLink')"/>
<action code="$waitForElement('id=totalPriceTR','2000')"/>
<action code="$callFunc('updateShoppingCartCount')"/>
<!-- Item Added: [addProdCode] -->
<if value1="[itemCountExpected]" op="gt" value2="0">
    <assert value1="[itemCountExpected]" op="eq" value2="[ShoppingCartItemCount]"
        else="Failed to add product [addProdCode], expecting [VALUE1] items, instead it had [VALUE2] items"
        passed="Passed addItem test" tags=""/>
</if>

MScript Intro - MScript Triggers

MScript Triggers are:

  • Executable, Collection of MScript Tags
  • Attached to States and Transitions
  • Called as Model Executes
  • Exceptions (Failures) Automatically Captured

press down arrow for feature details

MScript Intro - MScript Triggers

MScript Trigger Best Practice - Mbt_start:

  • Define and Load DataSets
  • Initialize User Variables

press down arrow for feature details

MScript Intro - MScript Triggers

MScript Trigger Best Practice - Mbt_end:

  • Cleanup Temporary Files
  • Release System/Backend Resources
  • Save Execution Stats
  • Save Execution Results to File/Database

press down arrow for feature details

MScript Intro - MScript Triggers

MScript Trigger Best Practice -
State onentry and Transition prep:

  • Prepare user variables for use
    by action and verify triggers:
    • Determine AUT state
    • Retrieve data required
    • Determine/calculate expected values

press down arrow for feature details

MScript Intro - MScript Triggers

MScript Trigger Best Practice -
State process and Transition action:

  • Output test case
  • Perform test automation
  • Record / document action performed

press down arrow for feature details

MScript Intro - MScript Triggers

MScript Trigger Best Practice -
State onexit and Transition verify:

  • Determine AUT attributes
  • Assert AUT attributes match expected values
  • Record / document action performed

press down arrow for feature details

MScript Intro - MScript Tags

  • Action/Command Tags - action, assert, guard, log
  • Misc Tags - dataset, seqout, comment
  • Flow Control Tags - if, while
  • Advanced Tags - db, execSQL, field, rowdata, scriptlet, sql


More Info at: MScript Tags

press down arrow for feature details

MScript Intro - MScript Tags

MScript if/while Tags:

  • Contain other MScript Tags
  • Can be Nested

press down arrow for feature details

MScript Intro - MScript Variables

Types of MScript Variables:

  • System Variables
  • User Variables

press down arrow for feature details

MScript Intro - MScript Variables

System Variables:

  • system settings
  • model state during execution
  • Two notations:
    • $getSysVar('varName')
    • [varName]

MScript Intro - Functions

Types of MScript Functions:

  • System functions
  • Plugin functions
  • User defined function
  • Custom MScript function

press down arrow for feature details

MScript Intro - Functions

System Functions:

  • Over 100 functions
  • Interact with model
  • Access to system file, database
  • Send email, tweeter message


More Info at: System Functions

press down arrow for feature details

MScript Intro - Functions

Plugin Functions:

  • Plugin must be enabled for model
  • Hundreds of plugin functions provide:
    • Interact with AUT
    • Access to backend resources/services
    • Perform special function


More Info at: Plugin Functions

THE END

Visit other tutorials Here

© TestOptimal LLC.