SyntheticTestResults

A SyntheticTestResults object reports the results of a completed user test execution by the Experience Manager Monitor test engine.

Properties

  • SyntheticTest test: (Read-only) The test reporting these results.

Methods

  • SyntheticAlarm[] getAlarms(): Returns an ordered array of all alarms generated during the latest test execution.

  • Number getFailCount(): Returns the number of alarms where SyntheticAlarm.isFailed() is True.

  • SyntheticAlarm[] getAlarmsBySeverity(Object severity): Returns an array containing any alarms with the specified severity. Valid severity values are listed in testEngine.constants severities.

  • String toString(): Returns a string representation of this object.

Description

A SyntheticTestResults object reports the results of a completed user test execution by the Experience Manager Monitor test engine. All properties are read-only. SyntheticTestResults objects are reported to the testEngine.onTestComplete event handler to support Synthetic Test Management functionality.

The following example shows how to use this and related objects and services to implement conditional execution of a test. The example is purposely simplified to show the core functionality without getting bogged down in details of configuration management.

Example

/*
 * Conditional execution: execute test identified in 'conditionalTestName' once if
 * a triggerScenario in 'mainTestName' produces a Critical alarm
 */
var mainTestName='test1';
var triggerScenarios='[1][5]';
var conditionalTestName='test2';

testEngine.onTestComplete=handleTestComplete;
testEngine.onScenarioComplete=handleScenarioComplete;

function handleTestComplete(testResults)
{
   if(testResults.test.name == conditionalTestName)
   { // stop conditional test once it runs once
      testEngine.deactivateTest(conditionalTestName);
   }
}

function handleScenarioComplete(alarm)
{
   // if this is the alarm is from the right test and its critical
   if(alarm.testName == mainTestName && 
      alarm.severity == testEngine.constants.SEV_CRITICAL)
   { 
      // and its one of the trigger scenarios
      if(triggerScenarios.indexOf('['+alarm.scenarioSeqNum + ']') >=0)
      { 
         // and we did not already start the conditional test
         if(!testEngine.getDeployment().getTest(conditionalTestName).enabled)
         { 
            // then start the conditional test
            testEngine.activateTest(conditionalTestName);
         }
      }
   }
}