![]() |
VOOZH | about |
dotnet add package Toxon.StepFunctionTesting --version 1.1.0
NuGet\Install-Package Toxon.StepFunctionTesting -Version 1.1.0
<PackageReference Include="Toxon.StepFunctionTesting" Version="1.1.0" />
<PackageVersion Include="Toxon.StepFunctionTesting" Version="1.1.0" />Directory.Packages.props
<PackageReference Include="Toxon.StepFunctionTesting" />Project file
paket add Toxon.StepFunctionTesting --version 1.1.0
#r "nuget: Toxon.StepFunctionTesting, 1.1.0"
#:package Toxon.StepFunctionTesting@1.1.0
#addin nuget:?package=Toxon.StepFunctionTesting&version=1.1.0Install as a Cake Addin
#tool nuget:?package=Toxon.StepFunctionTesting&version=1.1.0Install as a Cake Tool
Test AWS Step Functions state logic from .NET by running states through TestState with mocks.
dotnet add package Toxon.StepFunctionTesting
ThenReturn, ThenFail)StepFunctionResult containing the typed result (Success, Failed, CaughtError, Retriable) and state invocation historystates:TestState)states:TestStateThis library calls the AWS Step Functions TestState API, so tests are not fully offline.
using Amazon.StepFunctions;
using Toxon.StepFunctionTesting.Framework;
var definition = """
{
"StartAt": "Work",
"States": {
"Work": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"End": true
}
}
}
""";
var runner = new StepFunctionRunner(
new AmazonStepFunctionsClient(),
definition,
new StepFunctionRunnerOptions { RequireMocks = true });
var mocks = new Dictionary<string, IMockProvider>
{
["Work"] = new MockSequence()
.ThenReturn("{\"ok\":true}")
};
var result = await runner.RunAsync("{}", mocks);
if (result.Result is StepFunctionStateResult.Success success)
{
Console.WriteLine(success.Output);
}
foreach (var invocation in result.Invocations)
{
Console.WriteLine($"{invocation.State.StateName}: {invocation.Result.GetType().Name}");
}
var mocks = new Dictionary<string, IMockProvider>
{
["Fetch"] = new MockSequence()
.ThenFail("RetryableError")
.ThenReturn("{\"value\":123}"),
["Validate"] = new MockSequence()
.ThenFail("ValidationError", "missing required field")
};
RequireMocks is true, ALL task states must have mocks.SkipWaitStates is recommended for test speed, but will not evaluate any expression for wait duration or any assignments/state transformation on Wait statesIf you run tests in CI, ensure AWS credentials are available (for example via GitHub OIDC) and the assumed role includes states:TestState.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.