Commit graph

6472 commits

Author SHA1 Message Date
Sipke Schoorstra f7b7ea4d73
Add unit tests for FlowFork activity and enhance test utilities (#6995)
* Add unit tests for `FlowFork` activity and enhance test utilities

- Introduce `FlowForkTests` to validate activity behavior with various branch configurations.
- Extend `ActivityExecutionContextExtensions` with methods to retrieve and check outcomes.
- Modify `ActivityTestFixture` to ensure activities transition to `Running` status before execution.

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-21 15:31:31 +02:00
Sipke Schoorstra af84a70ddb
Fix file encoding 2025-10-20 20:13:32 +02:00
lukhipolito-nexxbiz fcd0b5ae9a
Feat/unit test coverage sendhttprequest (#6961)
* Unit test coverage for SendHttpRequest + useful extensions

* Update src/modules/Elsa.Workflows.Core/Extensions/ActivityExecutionContextExtensions.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update test/unit/Elsa.Activities.UnitTests/HTTP/SendHttpRequestTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update test/unit/Elsa.Activities.UnitTests/HTTP/SendHttpRequestTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Improvements on unit test and documentation for http

* Update doc/qa/test-guidelines.md

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>

* Improvements on maintainability of sendhttprequest unit tests

* Improving tests and scheduled activity evaluation for activity context

* Refactor and splitting unnecessary grouped tests

* Improvements on SendHttp Unit tests

* Improvements on tests

* Update test/unit/Elsa.Activities.UnitTests/HTTP/SendHttpRequestTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Small suggestions from copilot

* Update test/unit/Elsa.Activities.UnitTests/HTTP/SendHttpRequestTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* small copilot suggestion

* Introduce Scheduler Strategy Interfaces and Implementations for Workflow and Activity Execution Contexts (#6984)

* Introduce Scheduler Strategy Interfaces and Implementations for Workflow and Activity Execution Contexts

- Added `IWorkflowExecutionContextSchedulerStrategy` and `IActivityExecutionContextSchedulerStrategy` interfaces.
- Implemented `WorkflowExecutionContextSchedulerStrategy` and `ActivityExecutionContextSchedulerStrategy` for scheduling activities in workflows.
- Refactored scheduling logic to utilize the new scheduler strategies.
- Updated unit tests and test helpers to reflect refactoring, introducing fake implementations for testing purposes.
- Adjusted background execution scheduling and improved extensibility for custom scheduler strategies.

* Refactor `SendHttpRequestTests`: simplify scheduling assertions, use shared extensions, and standardize method naming. Streamline helper methods and remove unused test logic.

* Refactor: Replace `ActivityTestHelper` with `ActivityTestFixture` in unit tests for streamlined activity testing

- Introduced `ActivityTestFixture` with a fluent API for better test setup and execution of activities.
- Added extension methods `ActivityTestFixtureExtensions` and `ActivityTestFixtureHttpExtensions` for configuring attributes and HTTP services.
- Updated test guidelines and unit tests to use the new fixture and extensions.
- Removed `ActivityTestHelper`.

* Refactor: Move `ActivityTestFixture` and related extensions to shared project for reuse across test suites

- Consolidated `ActivityTestFixture`, `ActivityTestFixtureExtensions`, and `ActivityTestFixtureHttpExtensions` into `Elsa.Testing.Shared`.
- Updated namespaces and imports across unit tests to reflect new structure.
- Enhanced `AssertActivityAttributes` and added fluent configuration APIs.
- Adjusted `Directory.Packages.props` with new dependencies, including `NSubstitute` and `xunit.assert`.

* Refactor `SetVariableTests`: inline `ActivityTestFixture` initialization to simplify test setup.

* Refactor `ActivityTestFixture`: eliminate redundant field `_services`, add `UsedImplicitly` attributes, and improve service collection management

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add XML documentation for `ActivityExecutionContextExtensions`, detailing methods and parameters.

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add XML documentation for scheduler strategies and their methods

- Updated `IActivityExecutionContextSchedulerStrategy` and `IWorkflowExecutionContextSchedulerStrategy` interfaces with XML summaries for methods.
- Added XML documentation to implementations (`ActivityExecutionContextSchedulerStrategy`, `WorkflowExecutionContextSchedulerStrategy`) and test fakes for clarity.

* Refactor `WriteLineTests`: consolidate duplicate test logic, simplify setup with shared helper method, and enhance readability in assertions.

* Refactor `WriteLineTests` and `SetVariableTests`: replace `WriteLineAsync` assertions with synchronous `WriteLine`, streamline exception recording in `SetVariableTests`, and remove unused imports.

* Add `ParallelTests` for unit and integration testing with various scenarios (#6988)

- Added unit tests for `Parallel` activity to ensure proper scheduling of child activities, including empty and mixed activity cases.
- Added integration tests to validate execution flow and edge cases for `Parallel` activities (e.g., nested parallelism, fault handling).
- Enhanced `ScheduleChildrenAsync` in `Parallel` to handle no activity scenario by completing immediately.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add new unit and integration tests for activity input and expression evaluation (#6990)

* Introduce Scheduler Strategy Interfaces and Implementations for Workflow and Activity Execution Contexts

- Added `IWorkflowExecutionContextSchedulerStrategy` and `IActivityExecutionContextSchedulerStrategy` interfaces.
- Implemented `WorkflowExecutionContextSchedulerStrategy` and `ActivityExecutionContextSchedulerStrategy` for scheduling activities in workflows.
- Refactored scheduling logic to utilize the new scheduler strategies.
- Updated unit tests and test helpers to reflect refactoring, introducing fake implementations for testing purposes.
- Adjusted background execution scheduling and improved extensibility for custom scheduler strategies.

* Refactor `SendHttpRequestTests`: simplify scheduling assertions, use shared extensions, and standardize method naming. Streamline helper methods and remove unused test logic.

* Refactor: Replace `ActivityTestHelper` with `ActivityTestFixture` in unit tests for streamlined activity testing

- Introduced `ActivityTestFixture` with a fluent API for better test setup and execution of activities.
- Added extension methods `ActivityTestFixtureExtensions` and `ActivityTestFixtureHttpExtensions` for configuring attributes and HTTP services.
- Updated test guidelines and unit tests to use the new fixture and extensions.
- Removed `ActivityTestHelper`.

* Refactor: Move `ActivityTestFixture` and related extensions to shared project for reuse across test suites

- Consolidated `ActivityTestFixture`, `ActivityTestFixtureExtensions`, and `ActivityTestFixtureHttpExtensions` into `Elsa.Testing.Shared`.
- Updated namespaces and imports across unit tests to reflect new structure.
- Enhanced `AssertActivityAttributes` and added fluent configuration APIs.
- Adjusted `Directory.Packages.props` with new dependencies, including `NSubstitute` and `xunit.assert`.

* Refactor `SetVariableTests`: inline `ActivityTestFixture` initialization to simplify test setup.

* Refactor `ActivityTestFixture`: eliminate redundant field `_services`, add `UsedImplicitly` attributes, and improve service collection management

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add XML documentation for `ActivityExecutionContextExtensions`, detailing methods and parameters.

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add XML documentation for scheduler strategies and their methods

- Updated `IActivityExecutionContextSchedulerStrategy` and `IWorkflowExecutionContextSchedulerStrategy` interfaces with XML summaries for methods.
- Added XML documentation to implementations (`ActivityExecutionContextSchedulerStrategy`, `WorkflowExecutionContextSchedulerStrategy`) and test fakes for clarity.

* Refactor `WriteLineTests`: consolidate duplicate test logic, simplify setup with shared helper method, and enhance readability in assertions.

* Refactor `WriteLineTests` and `SetVariableTests`: replace `WriteLineAsync` assertions with synchronous `WriteLine`, streamline exception recording in `SetVariableTests`, and remove unused imports.

* Add new unit and integration tests for activity input and expression evaluation

- Introduced comprehensive test suites covering activity input evaluation, expression handling, and fault scenarios.
- Added unit tests for `ExpressionDescriptorRegistry`, `ExpressionEvaluator`, and activity execution context extensions.
- Added integration tests: `CustomInputEvaluatorTests`, `InputEvaluationErrorTests`, and `InputPropertyEvaluationTests`.
- Enhanced code coverage for edge cases and async evaluation logic.

* Remove unused `RunWorkflowAsync` extension method from `RunActivityExtensions`.

* Rename `CustomInputEvaluatorTests` to `InputEvaluationTests` for consistency with naming conventions.

* Remove unused `Elsa.Workflows.Activities` import from `RunActivityExtensions`.

* Remove redundant comments from `InputEvaluationErrorTests` for clarity.

* Refactor unit tests to streamline activity and expression evaluations

- Refactored `ExecuteActivityAsync` and `ExecuteWriteLineAsync` into shared helpers for consistency and reuse across tests.
- Replaced redundant mock setups with helper methods in `ExpressionDescriptorRegistryTests`.
- Simplified test setup for expression and activity evaluation by removing unused imports and consolidating configuration logic.
- Enhanced readability by reducing duplicate code and leveraging shared utility methods.

* Refactor activity input evaluation tests

- Extracted `CreateContextAsync` helper into `EvaluationTestHelpers` for reuse across evaluation test suites.
- Replaced inline activity context setup with shared helper in `InputPropertyEvaluationTests`, `WrappedInputEvaluationTests`, and related test suites.
- Simplified test method names for clarity and consistency.
- Updated test annotations to enhance readability and align with naming conventions.

* Remove redundant test cases and unused imports

- Deleted duplicated and non-essential test cases across evaluation test suites.
- Removed unused imports to improve code cleanliness and readability.
- Streamlined variable initializations and method calls within test setups.

* Remove redundant test case from `InputEvaluationErrorTests`

- Deleted the `ContinuesEvaluationForMultipleInputs` test, as it overlaps with existing tests and does not provide additional coverage.

* Remove redundant assertion from `InputPropertyEvaluationTests`

- Deleted `Assert.True(context.GetHasEvaluatedProperties())`, as it is unnecessary for verifying test outcomes.

* Remove redundant test cases from `WrappedInputEvaluationTests`

- Deleted `UsesDefaultValueWhenInputIsNull` and `EvaluatesExpression` tests as they are either duplicated or unnecessary for current test coverage.

* Add unit test projects for `Elsa.Workflows.Management` and `Elsa.Expressions`

- Introduced new test projects to separate and organize unit tests for `Elsa.Workflows.Management` and `Elsa.Expressions`.
- Updated `Elsa.sln` to include references to the newly added test projects.
- Adjusted namespaces in affected test classes for consistency with the updated project structure.

* Refactor `ExpressionEvaluatorTests` for clarity and consistency

- Simplified test method names and annotations for improved readability.
- Replaced duplicate mock setups with helper functions (`CreateContextAsync`, `CreateContextWithMockHandlerAsync`, and related methods).
- Streamlined test setups by removing redundant code and consolidating context creation logic.
- Updated test annotations to include descriptive `DisplayName` attributes.

* Apply suggestion from @Copilot

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Remove redundant comment from `ExpressionEvaluatorTests` for clarity

* Remove redundant blank lines from unit test classes

- Eliminated unnecessary blank lines across `ActivityExecutionContextExtensions` test suites to improve code readability and consistency.

* Update src/modules/Elsa.Expressions/Services/ExpressionEvaluator.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Expand `test-guidelines.md` with testing best practices, helper references, and example snippets

- Added detailed guidance on test project organization, updated helper documentation, and streamlined example code for activity unit testing.
- Introduced scheduler strategy information and integration test patterns for deterministic tests.
- Clarified usage of shared infrastructure like `ActivityTestFixture` and `AsyncWorkflowRunner`.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: lucas.hipolito <lukhipolito@yahoo.com.br>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2025-10-20 20:11:46 +02:00
lukhipolito-nexxbiz f85550b9a1
Merge pull request #6959 from elsa-workflows/feature/unit-test-coverage-writeline
Unit testing coverage for WriteLine activity
2025-10-14 13:34:15 +02:00
Sipke Schoorstra 35704e9166
Update doc/qa/test-guidelines.md 2025-10-14 12:45:23 +02:00
Sipke Schoorstra 3d15baf0f2
Update doc/qa/test-guidelines.md 2025-10-14 12:45:18 +02:00
lucas.hipolito 337d3629a5 Merge remote-tracking branch 'origin/feature/unit-test-coverage-writeline' into feature/unit-test-coverage-writeline 2025-10-13 19:31:35 +02:00
lucas.hipolito 7147eb5124 Improving maintainability of tests 2025-10-13 19:31:03 +02:00
lukhipolito-nexxbiz 4b0a27cc7f
Update test/unit/Elsa.Activities.UnitTests/Console/WriteLineTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-13 19:23:42 +02:00
lucas.hipolito ab7d0f6d55 Updated documentation to reflect test suite helpers 2025-10-13 17:07:56 +02:00
lucas.hipolito 15f33ead4a Merge branch 'develop/3.6.0' into feature/unit-test-coverage-writeline 2025-10-13 16:39:59 +02:00
lukhipolito-nexxbiz c04d4e246f
Merge pull request #6932 from elsa-workflows/feat/test-guidelines
Feat/test guidelines
2025-10-13 16:39:21 +02:00
lucas.hipolito 60d0f263a9 Merge remote-tracking branch 'origin/feat/test-guidelines' into feat/test-guidelines 2025-10-13 16:28:48 +02:00
lucas.hipolito bd6aea4498 Final Improvements 2025-10-13 16:28:33 +02:00
lukhipolito-nexxbiz f6caad19fb
Update doc/qa/test-guidelines.md
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2025-10-13 16:11:10 +02:00
lucas.hipolito d0aafe6d4e Removing out of scope tests 2025-10-13 15:02:38 +02:00
lucas.hipolito fe80505f21 Unit testing coverage for WriteLine activity 2025-10-10 10:30:24 +02:00
lucas.hipolito f1e69a1536 Small wording improvement 2025-10-09 16:55:12 +02:00
lukhipolito-nexxbiz e9ae53c4c6
Update doc/qa/test-guidelines.md
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2025-10-09 14:49:49 +02:00
lukhipolito-nexxbiz c9be7f0d13
Update doc/qa/test-guidelines.md
Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
2025-10-09 14:49:00 +02:00
lucas.hipolito 8ec29358b5 Equalizing with 3.6.0 2025-10-09 14:45:33 +02:00
lucas.hipolito 9ab15d3d15 Reverting wrong commits 2025-10-09 14:36:56 +02:00
lucas.hipolito e22ecf83a0 Merge branch 'develop/3.6.0' into feat/test-guidelines 2025-10-09 14:02:08 +02:00
lukhipolito-nexxbiz 695a33cb02
Merge pull request #6951 from elsa-workflows/feature/unit-test-suite
Feature/unit test suite
2025-10-09 13:34:29 +02:00
Sipke Schoorstra 5b014c7566
Apply suggestion from @Copilot
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-09 13:31:06 +02:00
lucas.hipolito 19b5ab94dd Workaround for using correct overoad - build fix 2025-10-09 09:59:04 +02:00
lucas.hipolito f407463238 Merge remote-tracking branch 'origin/feature/unit-test-suite' into feature/unit-test-suite 2025-10-09 09:41:31 +02:00
lucas.hipolito 9ea3f49e0f Small improvement for generic Variable type evaluation 2025-10-09 09:41:27 +02:00
lukhipolito-nexxbiz c7df5619e5
Update test/unit/Elsa.Activities.UnitTests/Primitives/SetVariableTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-09 09:40:36 +02:00
lukhipolito-nexxbiz c02484fd4d
Update src/modules/Elsa.Workflows.Core/Activities/SetVariable.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-09 09:40:01 +02:00
lukhipolito-nexxbiz abfaad85cb
Update test/unit/Elsa.Activities.UnitTests/Helpers/ActivityTestHelper.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-09 09:39:07 +02:00
lucas.hipolito c773d83733 Merge branch 'develop/3.6.0' into feature/unit-test-suite 2025-10-09 08:48:04 +02:00
lukhipolito-nexxbiz 2cbfa279c7
Merge pull request #6952 from elsa-workflows/feature/unit-test-suite-suggestions
PR suggestions from Sipke
2025-10-09 08:44:16 +02:00
Sipke Schoorstra 2abb937fc1
Add integration test for implicit join behavior with merge mode set to None 2025-10-08 21:10:35 +02:00
Sipke Schoorstra b5cc5f7ca5
Update coverlet.msbuild version to 6.0.4 in Directory.Packages.props 2025-10-08 20:36:06 +02:00
Sipke Schoorstra b3c1defd3d
Fix incorrect test method name to reflect expected throwing behavior when variable is null in SetVariableTests. 2025-10-08 20:27:18 +02:00
Sipke Schoorstra 8eb2b11f6e
Refactor SetVariable activity: add null safety checks, update variable property to nullable type, and enhance unit tests for edge cases. 2025-10-08 20:23:25 +02:00
lucas.hipolito e6df8ea954 More unit tests for set variable 2025-10-08 14:59:59 +02:00
lucas.hipolito 5bd037928c Helper for isolated activity testing + few SetVariable tests 2025-10-08 14:38:19 +02:00
lucas.hipolito 2fde7ef048 Merge branch 'develop/3.6.0' into feature/unit-test-suite 2025-10-08 09:07:53 +02:00
Sipke Schoorstra bbbf13c58c
Allow tests to run on all events
Remove condition to run tests only on pull requests.
2025-10-07 20:10:38 +02:00
Sipke Schoorstra fe4d74189a
Add coverage enforcement for test projects (#6950)
* Add coverage enforcement for test projects

* Expand GitHub Actions triggers to include additional branch patterns

* Update `coverlet.msbuild` configuration and centralize dependency version management

- Removed inline version specification for `coverlet.msbuild` in `test/Directory.Build.props`.
- Centralized `coverlet.msbuild` version definition in `Directory.Packages.props` for consistency and maintainability.

* Remove `Elsa.Common.Core` unit test project and related test files

* Add Directory.Build.props for test project organization and update property configurations

- Introduced `Directory.Build.props` files for `test/unit` and `test/integration` to define project-specific properties.
- Updated `test/Directory.Build.props` to include new coverage formats and an exclusion for `Elsa.Testing.Shared`.
- Adjusted solution file to link new `Directory.Build.props` files.
- Configured threshold properties for `unit`, `integration`, and `component` test directories.

* Disable coverage collection for performance tests in project file

* Expand GitHub Actions workflow triggers and add PR-specific condition for test job
2025-10-07 19:59:53 +02:00
lucas.hipolito 4a26819ed7 (WIP) Initial context helper + provisional unit tests for setvariable 2025-10-07 15:56:08 +02:00
lucas.hipolito 9ac605fbb5 Renaming guideline file 2025-10-07 09:03:16 +02:00
lucas.hipolito 3d9cefa894 Better and revised general testing guidelines 2025-10-06 17:54:11 +02:00
lucas.hipolito 4d17f869a3 Merge branch 'develop/3.6.0' into feat/test-guidelines 2025-10-06 13:45:41 +02:00
Sipke Schoorstra fcdb6f5499 Refactor WorkflowDefinitionManager: streamline constructor, remove unused field, and improve consistency in method calls. 2025-10-06 10:33:09 +02:00
Sipke Schoorstra 95b17135a9
Add support for reverting workflow definitions to a specific version and refactor WorkflowDefinitionFilter initialization for consistency 2025-10-05 15:08:42 +02:00
Sipke Schoorstra b52a07f46a
Refactor FlowchartNextActivity tests: reduce unused cases, update switch behaviors, and improve consistency. 2025-10-05 10:51:29 +02:00
Sipke Schoorstra d1051f3194
Remove unused connection definition in FlowchartNextActivity integration test. 2025-10-05 10:41:51 +02:00