danielgerlag / danielgerlag/workflow-core
Unit test does not execute step
- Dominant language
- C#
- Stars
- 5.9k
- Forks
- 1.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 5
Description
I have a unit test like this:
```
public class WorkflowUnitTests: WorkflowTest
{
private Mock _servicesMock;
public MyWorkflowUnitTests()
{
_servicesMock = new Mock();
// Set up mock methods
// ...
Setup();
}
[Fact]
public async Task Workflow_Sample_Test()
{
var workflowId = await StartWorkflowAsync(new CaseChanged()
{
Data = new CaseData()
{
CaseRecordId = 123
}
}) ;
await WaitForWorkflowToCompleteAsync(workflowId, TimeSpan.FromSeconds(10));
GetStatus(workflowId).Should().Be(WorkflowStatus.Complete);
UnhandledStepErrors.Count.Should().Be(0);
}
}
```
And the workflow:
```
public void Build(IWorkflowBuilder builder)
{
builder
.StartWith(context =>
{
Log.Information($"Starting workflow '{Id}'"); // => **this is called**
return ExecutionResult.Next();
})
.Then() // => **this step not**
.Input(step => step.CaseChanged, caseChanged => caseChanged)
.Then(context => Log.Information($"Workflow '{Id}' complete"));
}
```
And the step
```
public class UpdateStep : StepBodyAsync
{
public CaseChanged? CaseChanged { get; set; }
private IServices Services { get; }
public UpdateStep(IServices services)
{
Services = services;
}
public override async Task RunAsync(IStepExecutionContext context)
{
// ....
return ExecutionResult.Next();
}
}
```
The ctor of the step is also never called.
What can be the issue?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the WorkflowUnitTests setup and the workflow Build method, then trace StartWorkflowAsync through UpdateStep.RunAsync and its constructor. Run the sample test and inspect why the step is not instantiated or executed; done means the step runs, its constructor is called, and UnhandledStepErrors remains zero.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100