Added an XML validation assertion in a test step. This assertion is validating xml details and returning an error message. The ITR-->Test Events tab show the assertion result. Is there any way to save this assertion error message to a property?
All supported LISA/DevTest releases
It can be done by adding "EVENT_ASSERT" listener to capture the assertion result and save it into a LISA property. Follow the below steps.
//Create a custom eventlistener that handles the event_assert event
var custom_listener = new com.itko.lisa.test.TestEventListener(){
public void testEvent(com.itko.lisa.test.TestEvent testevent){
if(testevent.getEventId() == com.itko.lisa.test.TestEvent.EVENT_ASSERT){
testExec.setStateValue("fi_assertionResult",testevent.getLongDesc()); //tell what to do with the event. In this case stores the long message in the fi_assertionResult property
}
}
};
testExec.setStateValue("Custom_Listener",custom_listener); //Stores a referens to the eventlistener so it can be later removed.
testExec.getTestEventMgr().addListener(custom_listener,com.itko.lisa.test.TestEvent.noFilter); //Add the listener to the testcase
* Run your assertion. Save LISA property - fi_assertionResult value to a file.
var custom_listener = testExec.getStateObject("Custom_Listener");
if(custom_listener !=null){
testExec.log("Removing listener :" + custom_listener );
testExec.getTestEventMgr().removeListener(custom_listener); // Remove the listener from the testcase
}else {
testExec.log("Unable to remove listener :" + custom_listener );
}