Run time metadata addon


One interesting feature of Testsigma is allowing users to create customized NLPs to author tests. These NLPs are created using add-ons. There are cases where the details of the test case executions need to be fetched as part of these NLPs. Testsigma provides a class for this to aid the users. The class is RunMetaData.

Instances of the RunMetaData class provide the basic and relevant information about the test case executions. It returns information about the test data profile ID, dry test case result ID, the email of the user who triggered the test, the time of execution, and so on. The following article discusses how to access the test execution details or run metadata using the Testsigma add-on.

The following article discusses how to access the test execution details or run metadata using the Testsigma add-on.

  1. Create an add-on. For more information refer to create an add-on for automated action.
  2. To access the run metadata, we need to access the instance of the class RunMetaData. By default, an instance of the class RunMetaData, called runMetaData which contains data for every add-on NLP, is present in the add-on template. Hence the user is not required to create an instance of the class.
    Users can access the runMetaData object anywhere in an add-on while creating an NLP.Note that the runMetaData object is created for both dry test case executions and test plan executions.

    The RunMetaData class provides the following methods that are used to retrieve the run metadata:

Method Description
getTestDataId () Returns the test data profile ID which is available to the step that is being executed. Returns a long value.
getRunId () Returns the dry test case result ID (if the execution is a Dry Execution)
OR test plan result ID (if the execution is a test plan execution) in which the step is executing.
Returns a long value.
getIsAdHocRun() Returns true if the user is running a dry test case execution, false if the user is running a test plan execution.
getTriggeredType() Displays the event type of the trigger test case execution. It means if the execution was triggered by a manual, scheduled, or API action.
Return an ENUM value. For example, MANUAL, SCHEDULED, or API. s
getTriggeredByEmail() Returns the email ID of the user who initiated the execution.
Returns String value
getStartTime() Returns the time at which test case or test plan execution is started.
Returns String value

The following is a sample code for retrieving run metadata using the Testsigma add-on.
package com.kasyap.testsigma.addons.web;
import com.testsigma.sdk.ApplicationType;
import.com.testsigma.sdk.Result;
import com.testsigma.sdk.WebAction;
import com.testsigma.sdk.annotation.Action;
import org.openqa.selenium.NoSuchElementException;

@Action(actionText = "Verifying RunMetadata", applicationType = ApplicationType.WEB)
public class CustomNLP extends WebAction {
@Override
    protected Result execute() throws NoSuchElementException {
        logger.info("Triggered By : " + runMetaData.getTriggeredByEmail());
        logger.info("TestDataProfile ID available to step" + runMetaData.getTestDataId());
        logger.info("Execution Result ID: " + runMetaData.getRunId());
        logger.info("Is Dry Execution? : " + runMetaData.getIsAdHocRun());
        logger.info("TriggeredType (Manual/Scheduled/API) ? " + runMetaData.getTriggerType());
        logger.info("Execution Started at (UTC format) : " + runMetaData.getStartTime());
        return Result.SUCCESS;
    }
}

In the above code one could see that the run metadata is retrieved by accessing the RunMetaData instance and using the methods of it.