public class Sys extends Object
Provides system functions for MScript.
Constructor and Description |
---|
Sys(MbtScriptExecutor scriptExec_p)
INTERNAL USE ONLY
|
Modifier and Type | Method and Description |
---|---|
void |
abort(String msg_p)
raises Exception to cause the MBT execution to abort.
|
void |
activateState(String stateID_p)
activates a specific state in the current model resulting in all transitions originating from the specified state to
be dispatched for immediate execution.
|
MCase |
addMCase(String mcaseName_p)
Adds a new mcase and returns the MCase created that can be used to add navigation actions.
|
Page |
addPage(String pageName_p)
adds an UI page.
|
void |
addReqFailed(String tag_p,
String msg_p)
adds a failed requirement check/validation message to the requirement stat.
|
void |
addReqFailed(String tag_p,
String msg_p,
String assertID_p)
adds a failed requirement check/validation message to the requirement stat.
|
void |
addReqPassed(String tag_p,
String msg_p)
adds a successful requirement check/validation message to the requirement
stat.
|
void |
addReqPassed(String tag_p,
String msg_p,
String assertID_p)
adds a successful requirement check/validation message to the requirement
stat.
|
int |
addTestOutput(String text_p)
adds a line to the test output buffer to be written out to file at the end of
the execution with call to $SYS.saveTestOutput(...)
|
void |
assertFalse(String tag_p,
boolean condition_p,
String failMsg_p)
performs the assert on the condition passed in to be false.
|
void |
assertFalse(String tag_p,
boolean condition_p,
String failMsg_p,
String assertID_p)
performs the assert on the condition passed in to be false.
|
void |
assertTrue(String tag_p,
boolean condition_p,
String failMsg_p)
performs the assert on the condition passed in to be true.
|
void |
assertTrue(String tag_p,
boolean condition_p,
String failMsg_p,
String assertID_p)
performs the assert on the condition passed in to be true.
|
StateNode |
findState(String stateID_p)
returns the state node.
|
TransitionNode |
findTransition(String stateID_p,
String transID_p)
returns the transition node.
|
String |
genMSC(String chartLabel_p,
String fileName_p)
generate Message Sequence Chart (MSC) from the home/start state to the
current state.
|
String |
genMSC(String chartLabel_p,
String fileName_p,
String skinName_p)
generate Message Sequence Chart (MSC) from the home/start state to the
current state.
|
String |
genMSC(String chartLabel_p,
String fileName_p,
String skinName_p,
String bkgColor_p)
generate Message Sequence Chart (MSC) from the home/start state to the
current state.
|
String |
genPath(String fileName_p)
generate traversal graph from home/start state to the current state.
|
DataSet |
getCurDataSet()
returns the data set assigned to the current state / transition.
|
StateNode |
getCurState()
returns current state object
|
TransitionNode |
getCurTrans()
returns current transition
|
String |
getCurTravUID()
returns the UID of current traversal which can be either a transition or a state.
|
Object |
getData(String fieldName_p)
returns the the data for the field name specified from the dataset assigned to the current state / transition.
|
DataMgr |
getDataMgr()
returns DataMgr which manages all data sets created/registered for the model execution.
|
DataSet |
getDataSet(String dsName_p)
returns the data set that has been created and registered to the model execution.
|
String |
getEnvVar(String varName_p)
Returns the value (String) for the environment variable (global variable in current
server).
|
ExecutionDirector |
getExecDir()
returns execution director object of current model execution.
|
MCaseMgr |
getMCaseMgr()
returns MCaseMgr which manages all MCases created/registered for the model execution.
|
String |
getModelAbsolutePath()
returns absolute file path to the model folder
|
ScxmlNode |
getModelObj()
returns model object.
|
String |
getModelRelativePath()
returns relative file path to the model folder
|
PageMgr |
getPageMgr()
returns PageMgr which manages all page objects created/registered for the model execution.
|
String |
getPathName()
set current test path name.
|
ModelExecDB |
getStats()
returns the model execution stats collection object.
|
int |
getThreadID()
returns current virtual user (thread) id.
|
Map<String,Object> |
getVars()
returns all user variables.
|
boolean |
isModelRunning(String modelName_p)
returns true if the model specified is also running in the same server.
|
boolean |
isSubModel()
if the current model is a sub model.
|
void |
log(String msg_p)
logs a message to MScript log
|
Page |
page(String pageName_p)
returns page object for the page name specified.
|
Map<String,Map<String,Object>> |
readIndexMap(String filePath_p,
String indexColName_p)
reads a tab delimited file from model's report folder and index it on
the specified column for quick access.
|
List<Map<String,Object>> |
readTSV(String filePath_p)
reads a tab delimited file from model's dataset folder.
|
String |
saveTestOutput(String fileName_p)
saves the test output accumulated during model execution to a file.
|
boolean |
setAsyncTransThreadPoolSize(int threadPoolSize_p)
overrides the default AsyncTransThreadPoolSize setting from config.properties.
|
boolean |
setCurTransSatisfyingHint(String hint_p)
change the current transition's satisfying hint at runtime.
|
void |
setEnvVar(String varName_p,
String toValue_p)
Set environment variable to the specified value - String only.
|
void |
setMaxAsyncTrans(int maxSize_p)
overrides the default MaxAsyncTrans setting from config.properties.
|
void |
setPathName(String name_p)
returns current test path name.
|
boolean |
setSeed(String seed_p)
initialize random number generator used by the sequencer to the specific
seed.
|
boolean |
setTransGuardHint(String hint_p)
change the current transition's guard hint at runtime.
|
String |
trace()
returns the trace in a string of the traversals separated by comma leading up to
the current state/transition.
|
String |
trace(int maxTraceCount_p,
String delimiter_p)
returns the trace in a string of last maxLogCount_p traversals leading up to
the current state/transition.
|
public Sys(MbtScriptExecutor scriptExec_p)
INTERNAL USE ONLY
scriptExec_p
- public void log(String msg_p)
msg_p
- public void abort(String msg_p) throws Exception
Can be used anywhere in mScript. It will trigger Error if one is declared.
This function is ignored when running the model in debug mode and AUT is disabled. The reason for this behavior is to allow users to continue to debug MScript error. Instead of abort the execution, it will just display an abort alert message indicating where the abort was triggered.
Example: $sys.abort('Fatal error detected')
Exception
public boolean isModelRunning(String modelName_p)
$SYS.isModelRunning('model2')
modelName_p
- name of the modelpublic String trace() throws Exception
Example: place in MBT_FAIL
or MBT_ERROR
triggers
to print out the test sequence transitions
that led to the current state/transition where the error/failure occurred.
Example:
$SYS.trace()
ContinueShopping:U101,AddItem:U112
Exception
public String trace(int maxTraceCount_p, String delimiter_p) throws Exception
Example: place in MBT_FAIL
or MBT_ERROR
triggers
to print out the test sequence transitions
that led to the current state/transition where the error/failure occurred.
$SYS.trace(5,'|')
maxTraceCount_p
- max number of traversalsdelimiter_p
- delimiter to be used to separate the traversals.ContinueShopping:U101|AddItem:U112
Exception
public String genPath(String fileName_p) throws Exception
CAUTION: this function is not thread-safe, i.e. if you are running multiple concurrent threads, the behavior may be un-predictable - it may contain traversals from other threads concurrently running.
fileName_p
- name of the image file without extension. You may include "." in
the file name, but the system will always add file extension that
matches the image even if you have supplied the right extension.Exception
public String genMSC(String chartLabel_p, String fileName_p) throws Exception
CAUTION: this function is not thread-safe, i.e. if you are running multiple concurrent threads, the behavior may be un-predictable - it may contain traversals from other threads concurrently running.
fileName_p
- name of the image file without extension. You may include "." in
the file name, but the system will add file extension that matches
the image even if you have supplied the right extension.Exception
public String genMSC(String chartLabel_p, String fileName_p, String skinName_p) throws Exception
CAUTION: this function is not thread-safe, i.e. if you are running multiple concurrent threads, the behavior may be un-predictable - it may contain traversals from other threads concurrently running.
fileName_p
- name of the image file without extension. You may include "." in
the file name, but the system will add file extension that matches
the image even if you have supplied the right extension.skinName_p
- name of the skin (Rose or BlueModern) to style the MSC.Exception
public String genMSC(String chartLabel_p, String fileName_p, String skinName_p, String bkgColor_p) throws Exception
CAUTION: this function is not thread-safe, i.e. if you are running multiple concurrent threads, the behavior may be un-predictable - it may contain traversals from other threads concurrently running.
fileName_p
- name of the image file without extension. You may include "." in
the file name, but the system will add file extension that matches
the image even if you have supplied the right extension.skinName_p
- name of the skin (Rose or BlueModern) to style the MSC.bkgColor_p
- background color to be used for MSC, use HTML color codeException
public boolean setTransGuardHint(String hint_p)
Guard hint is a code (or codes separated by comma).
Example:$SYS.setCurTransGuardHint('Login')
The above example sets the guard hint on the current transition to
Login
. When traversing this transition but the guard fails, the
sequencer will attempt to find the transitions with the satisfying hint that
matches the guard hint.
The assumption is that when the transition with the matching satisfying hint is traversed, it will make the guard condition to true and this this transition can be traverse next.
Can not be used in Debug Expression
hint_p
- public boolean setCurTransSatisfyingHint(String hint_p)
Must be executing a transition.
Satisfying hint is a code (or codes separated by comma).
Example:$SYS.setCurTransSatisfyingHint('Login')
The above example sets the satisfying hint on the current transition to
Login
.
Can not be used in Debug Expression
hint_p
- public StateNode findState(String stateID_p)
stateID_p
- state id or state uidpublic TransitionNode findTransition(String stateID_p, String transID_p)
stateID_p
- state id or uidtransID_p
- transition id onlypublic boolean setSeed(String seed_p)
This function is usually called in the MBT_start trigger. However you may call it anywhere in MScript.
seed_p
- public String getEnvVar(String varName_p) throws MBTException
Example:
$SYS.getEnvVar('var1')
varName_p
- name of the variable.MBTException
public void setEnvVar(String varName_p, String toValue_p) throws Exception
$SYS.setEnvVar('myVar','123')
varName_p
- variable nametoValue_p
- new valueException
public ExecutionDirector getExecDir()
public void assertTrue(String tag_p, boolean condition_p, String failMsg_p) throws Exception
tag_p
- one single tag idcondition_p
- boolean conditionfailMsg_p
- message to be added to this check if condition_p is false.Exception
public void assertTrue(String tag_p, boolean condition_p, String failMsg_p, String assertID_p) throws Exception
tag_p
- one single tag idcondition_p
- boolean conditionfailMsg_p
- message to be added to this check if condition_p is falseassertID_p
- user assigned unique id for this specific call, this is usually
used to find the same defect in the defect system from previous
runs.Exception
public void assertFalse(String tag_p, boolean condition_p, String failMsg_p) throws Exception
tag_p
- one single tag idcondition_p
- boolean conditionfailMsg_p
- message to be added to this check if condition_p is true.Exception
public void assertFalse(String tag_p, boolean condition_p, String failMsg_p, String assertID_p) throws Exception
tag_p
- one single tag idcondition_p
- boolean conditionfailMsg_p
- message to be added to this check if condition_p is trueassertID_p
- user assigned unique id for this specific call, this is usually
used to find the same defect in the defect system from previous
runs.Exception
public void addReqPassed(String tag_p, String msg_p) throws Exception
tag_p
- one single tag idmsg_p
- message to be added to this check.Exception
public void addReqPassed(String tag_p, String msg_p, String assertID_p) throws Exception
tag_p
- one single tag idmsg_p
- message to be added to this check.assertID_p
- user assigned unique id for this specific call, this is usually
used to find the same defect in the defect system from previous
runs.Exception
public void addReqFailed(String tag_p, String msg_p) throws Exception
tag_p
- one single tag idmsg_p
- message to be added to this check.Exception
public void addReqFailed(String tag_p, String msg_p, String assertID_p) throws Exception
tag_p
- one single tag idmsg_p
- message to be added to this check.assertID_p
- user assigned unique id for this specific call, this is usually
used to find the same defect in the defect system from previous
runs.Exception
public int addTestOutput(String text_p) throws Exception
text_p
- Exception
public String saveTestOutput(String fileName_p) throws Exception
fileName_p
- Exception
public ModelExecDB getStats() throws Exception
Exception
public ScxmlNode getModelObj()
public String getModelRelativePath()
public String getModelAbsolutePath()
public int getThreadID()
public void setPathName(String name_p)
public String getPathName()
public boolean isSubModel()
public StateNode getCurState()
Can not be used in Debug Expression
public TransitionNode getCurTrans()
Can not be used in Debug Expression
public String getCurTravUID()
Can not be used in Debug Expression
public DataSet getCurDataSet() throws MBTAbort
Can not be used in Debug Expression
MBTAbort
public Object getData(String fieldName_p) throws MBTAbort
MBTAbort
public boolean setAsyncTransThreadPoolSize(int threadPoolSize_p)
Default value is 5.
Example: $SYS.setAsyncTransThreadPoolSize(10)
The above example overrides the maximum number of transitions to be executing at any time to 10.
threadPoolSize_p
- public void setMaxAsyncTrans(int maxSize_p)
Default value is 50.
Example: $SYS.setMaxAsyncTrans(100)
The above example overrides the maximum number of transitions allowed to wait for execution to 100.
maxSize_p
- public void activateState(String stateID_p) throws Exception, MBTAbort
This should only be used for Concurrent models
Can not be used in Debug Expression
public DataMgr getDataMgr()
public DataSet getDataSet(String dsName_p) throws MBTAbort
dsName_p
- MBTAbort
public PageMgr getPageMgr()
public Page page(String pageName_p) throws MBTAbort
pageName_p
- MBTAbort
- if page not foundpublic MCaseMgr getMCaseMgr()
public MCase addMCase(String mcaseName_p) throws MBTAbort
mcaseName_p
- MBTAbort
public Page addPage(String pageName_p) throws MBTAbort
pageName_p
- MBTAbort
public List<Map<String,Object>> readTSV(String filePath_p) throws Exception
filePath_p
- Exception
public Map<String,Map<String,Object>> readIndexMap(String filePath_p, String indexColName_p) throws Exception
filePath_p
- indexColName_p
- Exception
Copyright TestOptimal, LLC