elsa-workflows / elsa-workflows/elsa-core

Output of Write activity that is using context is not captured in tests

Open
#6,724 0 comments 0 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

## Description
I am trying to diagnose a problem and to improve test created for PR. The output of `Write` activity that is using context is not captured in tests.

The `Write` activity is defined as follows
```
new WriteLine(context => $"Running subroutine, " +
$"correlation id is '" + context.GetWorkflowExecutionContext().CorrelationId + "'.")
{
Id = "WriteLine ChildWorkflow"
},
```

And `CapturingTextWriter` captures the following
```
"Start Parent",
"Start ChildWorkflow",
""
"Finish ChildWorkflow",
"Finish Parent"
```

## Steps to Reproduce
Attached is the executable test, place in it `Elsa.Workflows.IntegrationTests.Scenarios.RunAsynchronousActivityOutput` namespace.

1. **Detailed Steps**: Run the attached test

2. **Code Snippets**: If the issue involves code (e.g., JavaScript error, server request failure), include the relevant snippets where the issue occurs.

3. **Attachments**:
- **Test**: [Test.cs.txt](https://github.com/user-attachments/files/20687423/Test.cs.txt)
- **Dispatch extensions**: to set correlation id and register additional workflows [DispatchWorkflowExtensions.cs.txt](https://github.com/user-attachments/files/20687440/DispatchWorkflowExtensions.cs.txt)

4. **Reproduction Rate**: every time

## Expected Behavior
`CapturingTextWriter` should capture
```
"Start Parent",
"Start ChildWorkflow",
"Running subroutine, correlation id is 'test-correlation-id'.",
"Finish ChildWorkflow",
"Finish Parent"
```

## Actual Behavior
Output from child activity is not captured.

## Environment
- **Elsa Package Version**: I am using the latest source code (last commit hash is 5fbe2775681e916e22b13b254d7a063802437783)
- **Operating System**: Windows 10

## Troubleshooting Attempts
I tried to debug it and found out that different instances of `Write` activity are used.

When constructor is invoked (see the source)
![Image](https://github.com/user-attachments/assets/032cc825-ece1-4f4b-a114-d0684b1a9f45)

And when activity is executed - source matches, but `Text` is null:
![Image](https://github.com/user-attachments/assets/3b2f8c43-949d-41e9-80c7-773bcbc99ec8)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.