Testing Automation Scripts with the new Maximo 7.6 “Testscript” method (Part 1: MBO based scripts)
Maximo introduced with Version 7.6 a new feature which allows you to test your automation scripts in context of a new or an existing Mbo as well as in context of the Maximo Integration Framework (MIF). The downside of that new function is, that I currently have not found any good documentation and that some features like the object path syntax are not self explaining. In this two part series I would like to introduce the new “Testscript” feature and explain how easy it is to use for your daily script testing. In part 1 we will cover the test of scripts in context of a Mbo and in part two I will show you how to test in context of the MIF.
The old styled “Run Script” testing is no longer visible but can be enabled again using the trick in my other post.
The first thing to mention if you want to test a script with the new Mbo-Test functionality is, that you need to have a script with an Object Launchpoint. Scripts with attribute launchpoints are not tested, or even worse if you have both: an object launch point and a attribute launch point on the same Mbo always the object script runs, even you select the attribute launch point script! (Might be confusing!). On the the other hand side you could utilize an Object Launchpoint testscript to set a certain attribute in a Mbo which then triggers the attribute launchpoint as well 😉
Now lets create a very simple script with an object launch point for the ASSET object like the following:
print "Hello World" print mbo.getString("ASSETNUM")
Press the “Test Script” button and you will see the following dialog:
At the top you will see information about the script and the selected Launchpoint we are running on.
With 1. you will select if we want the script to be tested against a newly created object or and existing object.
In 2. an object path can be specified if we want to reference an existing object. The format I currently found out is:
Examples could be:
ASSET[ASSETNUM='11200'] ASSET[ASSETNUM like '11%'] ASSET[ISRUNNING = 1] ITEM[ITEMNUM='0815']
Important to remember, that you always get only a single resulting record to your script. This is the default behavior for an object script, where the resulting set is stored in the implicit Launchpoint variable mbo.
If you select Existing Object and specify an Object Path (remember to copy the Object Path to the clipboard – you have to reenter it for every test!) you can press the Test button.
- Data contains the resulting MBO in XML format.
- Log contains the output of the Print statements of the script.
With the Set attribute values section you can specify attributes which are overwritten from the original result. This is a nice feature when you need some testing data with certain specification (e.G. We need an asset in status of not running (ISRUNNING = 0), so we just need to specify:
So far we just have discussed the Existing Object path. If you like to create a New Object this also can be done with the testing function. The testing function basically calls an mboSet.addAtEnd() function to append a new record to the given MboSet. With the usage of Set attribute values you can predefine fields of the newly created Mbo before it is handed over to the Jython script.
A bit strange is, that if you try to create an Asset Object and do not specify an ASSETNUM you will get an error, that the asset field needs to be specified. If you will set the ASSETNUM field you will get an error, that it is readonly and cannot be set.
The only solution I found so far is to hardly overwrite the readonly check by using the Field Flag “NOACCESSCHECK”:
from psdi.mbo import MboConstants mbo.setValue("ASSETNUM", "ASS0815", MboConstants.NOACCESSCHECK ) mbo.setValue("DESCRIPTION", "New Test Asset!")
So far for this first tutorial on the new Test script capability. In the next part I will cover the capability to test automation scripts customizing the MIF Interface.