.NET result reporting extensions

To create a .NET result reporting extension,

  1. Creating a Class Library project in Visual Studio.
  2. Add a reference to SkySparc.Platform.Plugin.dll in your OmniFi installation directory.
  3. Add a class to the project and let it extend the abstract class SkySparc.Platform.Plugin.NET.ACustomResultReportingExtension.
  4. Implement the abstract methods om ACustomResultReportingExtension.

Constructor

The constructor is required, and accepts the system, user, and password. The user and password are credentials mapped in the OmniFi Administration application.

public class MyDotNetResultReportingExtension : ACustomResultReportingExtension
{
    public MyDotNetResultReportingExtension(string System, string UserId, string Password)
            : base(System, UserId, Password)
    {
    }
}

GetConfigurationOptionsImpl

Configuration options are extension specific input parameters that are configured when the extension is configured in Autotest. Parameters are either statically configured or linked to the test plan via variables, i.e. dynamic and changing with the test plan item being reported.
The method GetConfigurationOptionsImpl() provides metadata for supported options in the form of a List<Plugin_Parameter>.

public override List<Plugin_Parameter> GetConfigurationOptionsImpl()
{
    return new List<Plugin_Parameter>
    {
        new Plugin_Parameter
        {
            Type = Plugin_DataType.STRING,
            Mandatory = true,
            Name = "outputFile",
            Description = "Output File"
        },
        new Plugin_Parameter
        {
            Type = Plugin_DataType.STRING,
            Mandatory = false,
            Name = "testCaseId",
            Description = "Test Case ID"
        },
        new Plugin_Parameter
        {
            Type = Plugin_DataType.BOOL,
            Mandatory = true,
            Name = "success",
            Description = "Success"
        }
    };            
}

Typical usage includes:

  • Static configuration such as an API URL to a target system, or an email address.
  • Runtime values and references, such as test-case-id.

ExportResultImpl

Export result is the main worker of the extension. It is important to note that the ExportResultImpl() method may be executed any number of times for different items during an execution. This means you must be careful to avoid modifying the script state during execution.

public override void ExportResultImpl(
    List<Plugin_Argument> Options,
    List<Plugin_Argument> Result)
{
    Logger.Debug("ExportResultImpl(): Enter");
    var options = Options.ToDictionary((x) => x.ParameterName);
    var result = ParseTestResult(Result);
    Plugin_Argument fileArg, testCaseIdArg, successArg;
 
    if (!options.TryGetValue("outputFile", out fileArg)
        || String.IsNullOrEmpty(fileArg.StringValue))
    {
        throw new ArgumentException("Output File not supplied");
    }
    string outputFile = fileArg.StringValue;
 
    string testCaseId;
    if (options.TryGetValue("testCaseId", out testCaseIdArg)
        && testCaseIdArg.StringValue != null)
    {
        testCaseId = testCaseIdArg.StringValue;
    }
    else
    {
        Logger.Warning(
            "ExportResultImpl(): No Test Case ID supplied, reverting to default.");
        testCaseId = result.Path;
    }
 
    if (!options.TryGetValue("success", out successArg)
        || successArg.BooleanValue == null)
    {
        throw new ArgumentException("Success not supplied");
    }
    bool success = (bool)successArg.BooleanValue;
 
    var directory = Path.GetDirectoryName(outputFile);
    if (!Directory.Exists(directory))
        Directory.CreateDirectory(directory);
            
    var lastExecuted = result.LastExecuted.ToString("yyyy-MM-dd hh:mm:ss");
 
    Logger.Trace("ExportResultImpl(): using file: " + outputFile);
 
    File.AppendAllLines(
        outputFile, 
        new string[] { $"{testCaseId};{lastExecuted};{success}" });
    Logger.Debug("ExportResultImpl(): Leave");
}

Options argument

Configuration option values are provided as a List<Plugin_Argument> by the options method argument.

Result argument

The result argument is a List<Plugin_Argument> describing the full execution result. Please see Result reporting data for detailed description of this data structure.

Shutdown

The Shutdown() method is called just before the extension is closed, allowing you to clean up any cached state.