Table of Contents

Class RecordTest

Namespace
Acuit.Pinpoint.Workflows.Testing.Activities
Assembly
Acuit.Pinpoint.Workflows.Testing.dll

Performs a unit test.

public class RecordTest : Activity, IActivity
Inheritance
RecordTest
Implements
Inherited Members

Examples

<RecordTest xmlns="http://schemas.acuit.com/pinpoint/2020/xaml/workflows"
            TestTypeName="[param.TestTypeName]">
  <RecordTest.Parameters>
    <Parameter Name="TestTypeName" Type="string" Description="The Acuit Pinpoint test type name to use for test results. This test type must exist in the line configuration. This is provided by Acuit Pinpoint Workstation and does not need to be configured." />
  </RecordTest.Parameters>
  <Sequence>
    <!-- The activities making up the test process go here... -->
  </Sequence>
</RecordTest>

Remarks

This activity encapsulates all of the logic for a single unit test. A passed or failed test result will always be saved by this activity, except when the activity has been canceled, when there is no unit scanned at the station (to allow using this workflow for manual tests), when an initialization error occurs (i.e., before the Body activity starts executing), or when an error occurs while executing the Fail activity.

Child activities can fail the running test by throwing a TestFailedException with its Reason set as desired. If an unhandled exception occurs while Body is executing, then it will be caught and result in a failed test result with "Unexpected error" as the reason, and a test data item added named "UnexpectedError" containing the unhandled exception message (including inner exception messages). When Body completes successfully, a passed test result will be saved. When a test fails, Fail will run (if set), and then a failed test result will be saved. If an unhandled exception occurs while Fail is executing, then no test result will be saved. SetTestDataItem can be used by child activities to add to the custom test data that will be saved with the unit test result.

This activity will emit "Starting test" to the test log as it starts, and if the test fails, it will emit "The test failed: {Reason}", where "{Reason}" will be the test fail reason, and any inner exception message(s) appended.

This activity provides the following additional services:

Service Type Description Provided to Body Provided to Fail
IActiveTest The active test. Yes Yes
ITestLog The active test log. Note that this will be the same as the Log property of the IActiveTest service. Yes Yes

This activity provides the following parameters:

Parameter Name Type Description Provided to Body Provided to Fail
RecordTest_ActiveTest IActiveTest The IActiveTest service instance. Yes Yes
RecordTest_TestFailedException TestFailedException The exception representing the failed test. No Yes

Fields

MaxReasonLength

The maximum length of test failure reasons.

public const int MaxReasonLength = 50

Field Value

int

Properties

Body

Gets or sets the optional activity that performs the test. If this is not set, a passed test will immediately be recorded.

public IActivity Body { get; set; }

Property Value

IActivity

Fail

Gets or sets an optional activity that will be run when a test fails for any reason (including due to an unhandled exception), before saving the failed test result.

public IActivity Fail { get; set; }

Property Value

IActivity

Notes

Gets or sets the optional notes to be saved with the test result (whether passed or failed). This is not evaluated until the test result is being saved.

public ValueSource<string> Notes { get; set; }

Property Value

ValueSource<string>

Remarks

This could be used to allow an operator to enter notes by setting this to an expression that references a variable (e.g., [var.TestNotes]), and then using activities within Body and/or Fail to set that variable to notes entered by the operator.

TestTypeName

Gets or sets the test type name used when saving the test result. This is required and is typically set via the "TestTypeName" parameter automatically provided by Acuit Pinpoint Workstation.

public ValueSource<string> TestTypeName { get; set; }

Property Value

ValueSource<string>

Methods

OnExecuteAsync(ActivityContext, CancellationToken)

Derived classes must implement this to perform the activity.

protected override Task OnExecuteAsync(ActivityContext context, CancellationToken cancellationToken)

Parameters

context ActivityContext

The activity context.

cancellationToken CancellationToken

The cancellation token used to request canceling the activity.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

ArgumentNullException

context is null.

InvalidOperationException

A service required by the activity is not available, or a required activity property value is not set. This will only occur asynchronously, wrapped in an AggregateException as the faulted task's Exception.

Exception

An error occurred while performing the activity. This will only occur asynchronously, wrapped in an AggregateException as the faulted task's Exception.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

Remarks

This is expected to produce a string suitable for labeling this activity in a workflow diagram. It should be as specific as possible, but while keeping it very short. In general, it should be the short name of the class (as that is how it would typically be defined in the workflow XAML), optionally followed by other property values of interest in a diagram. The default implementation returns the short name of the class.