Skip to content

Commit f5308ad

Browse files
authored
Changes for 1.9.0.
1 parent 766758e commit f5308ad

File tree

111 files changed

+1102
-248
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1102
-248
lines changed

.azure-devops/pipelines/build.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ jobs:
4747
inputs:
4848
command: restore
4949
verbosityRestore: Normal
50-
projects: '$(System.DefaultWorkingDirectory)/**/*.csproj'
50+
projects: '$(System.DefaultWorkingDirectory)/src/LogicAppUnit.sln'
5151

5252
- task: DotNetCoreCLI@2
5353
displayName: 'Build (${{ parameters.buildConfiguration }})'
5454
inputs:
5555
command: build
5656
arguments: '--no-restore --configuration ${{ parameters.buildConfiguration }}'
57-
projects: '$(System.DefaultWorkingDirectory)/**/*.csproj'
57+
projects: '$(System.DefaultWorkingDirectory)/src/LogicAppUnit.sln'
5858

5959
# Install and configure Logic Apps runtime environment
6060

@@ -94,12 +94,24 @@ jobs:
9494
# Run tests and publish test results to Azure DevOps
9595

9696
- task: DotNetCoreCLI@2
97-
displayName: 'Run tests'
97+
displayName: 'Run tests (not Windows)'
98+
condition: and(succeeded(), ne(variables.matrixName, 'Windows'))
99+
continueOnError: true
100+
inputs:
101+
command: test
102+
arguments: '--no-restore --verbosity normal --configuration ${{ parameters.buildConfiguration }} --filter TestCategory!="WindowsOnly"'
103+
projects: '$(System.DefaultWorkingDirectory)/src/LogicAppUnit.sln'
104+
publishTestResults: true
105+
testRunTitle: 'Tests ($(matrixName))'
106+
107+
- task: DotNetCoreCLI@2
108+
displayName: 'Run tests (Windows)'
109+
condition: and(succeeded(), eq(variables.matrixName, 'Windows'))
98110
continueOnError: true
99111
inputs:
100112
command: test
101113
arguments: '--no-restore --verbosity normal --configuration ${{ parameters.buildConfiguration }}'
102-
projects: '$(System.DefaultWorkingDirectory)/**/*.Tests.csproj'
114+
projects: '$(System.DefaultWorkingDirectory)/src/LogicAppUnit.sln'
103115
publishTestResults: true
104116
testRunTitle: 'Tests ($(matrixName))'
105117

@@ -109,6 +121,6 @@ jobs:
109121
displayName: 'Publish NuGet package (Release build only)'
110122
condition: and(succeeded(), eq('${{ parameters.buildConfiguration }}', 'Release'))
111123
inputs:
112-
targetPath: '$(System.DefaultWorkingDirectory)/LogicAppUnit/bin/${{ parameters.buildConfiguration }}'
124+
targetPath: '$(System.DefaultWorkingDirectory)/src/LogicAppUnit/bin/${{ parameters.buildConfiguration }}'
113125
artifact: 'NuGetPackage-$(matrixName)'
114126
publishLocation: 'pipeline'

.github/workflows/build.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ jobs:
3232
dotnet-version: 6.0.x
3333

3434
- name: Restore dependencies
35-
run: dotnet restore
35+
run: dotnet restore ${{ github.workspace }}/src/LogicAppUnit.sln
3636

3737
- name: Build
38-
run: dotnet build --no-restore
38+
run: dotnet build ${{ github.workspace }}/src/LogicAppUnit.sln --no-restore
3939

4040
# Install and configure Logic Apps runtime environment
4141

@@ -65,7 +65,12 @@ jobs:
6565
# Run tests
6666

6767
- name: Run tests
68-
run: dotnet test --no-restore --verbosity normal --logger "trx"
68+
if: success() && matrix.os != 'windows-latest'
69+
run: dotnet test ${{ github.workspace }}/src/LogicAppUnit.sln --no-restore --verbosity normal --logger "trx" --filter TestCategory!="WindowsOnly"
70+
71+
- name: Run tests
72+
if: success() && matrix.os == 'windows-latest'
73+
run: dotnet test ${{ github.workspace }}/src/LogicAppUnit.sln --no-restore --verbosity normal --logger "trx"
6974

7075
# Publish artefacts and test results
7176

@@ -74,13 +79,13 @@ jobs:
7479
if: success() || failure()
7580
with:
7681
name: test-results.${{ matrix.os }}
77-
path: ${{ github.workspace }}/LogicAppUnit.Samples.LogicApps.Tests/TestResults/*.trx
82+
path: ${{ github.workspace }}/src/LogicAppUnit.Samples.LogicApps.Tests/TestResults/*.trx
7883

7984
- name: Publish test results
8085
if: (success() || failure()) && github.event_name != 'pull_request'
8186
uses: dorny/test-reporter@v1
8287
with:
8388
name: Test Results (${{ matrix.os }})
84-
path: ${{ github.workspace }}/LogicAppUnit.Samples.LogicApps.Tests/TestResults/*.trx
89+
path: ${{ github.workspace }}/src/LogicAppUnit.Samples.LogicApps.Tests/TestResults/*.trx
8590
path-replace-backslashes: true
8691
reporter: dotnet-trx

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ mono_crash.*
2323
[Rr]eleases/
2424
x64/
2525
x86/
26+
[Ww][Ii][Nn]32/
2627
[Aa][Rr][Mm]/
2728
[Aa][Rr][Mm]64/
2829
bld/
@@ -61,6 +62,9 @@ project.lock.json
6162
project.fragment.lock.json
6263
artifacts/
6364

65+
# ASP.NET Scaffolding
66+
ScaffoldingReadMe.txt
67+
6468
# StyleCop
6569
StyleCopReport.xml
6670

@@ -137,6 +141,11 @@ _TeamCity*
137141
.axoCover/*
138142
!.axoCover/settings.json
139143

144+
# Coverlet is a free, cross platform Code Coverage Tool
145+
coverage*.json
146+
coverage*.xml
147+
coverage*.info
148+
140149
# Visual Studio code coverage results
141150
*.coverage
142151
*.coveragexml
@@ -348,3 +357,6 @@ MigrationBackup/
348357

349358
# Ionide (cross platform F# VS Code tools) working folder
350359
.ionide/
360+
361+
# Fody - auto-generated XML schema
362+
FodyWeavers.xsd

ChangeLog.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1+
# 1.9.0 (23rd January 2024)
2+
3+
LogicAppUnit Testing Framework:
4+
5+
- Improved the logging when using the Fluent API to match requests based on request headers or query parameters. When the actual and expected header or query parameter values do not match, both values are logged to make it easier to diagnose any test issues. Previous versions of the framework logged the match failure but did not log the actual and expected values.
6+
- Added `IMockRequestMatcher.FromAction(string[] actionNames)` to allow a mock request matcher to match a request based on the name of the workflow action that created the request. This feature depends on the `x-ms-workflow-operation-name` header being present in the request. Refer to the [wiki](https://github.com/LogicAppUnit/TestingFramework/wiki) for details of when the Logic App runtime creates this header.
7+
- Retry policies for actions using a managed API connection are removed and replaced with a `none` policy. This is the same pre-processing that is applied to HTTP actions. Previous versions of the framework did not remove the retry policies for actions using a managed API connection which meant that tests could take a long time to complete if they were testing failure scenarios.
8+
- The framework checks the `connections.json` file and will fail a test if there are any managed API connections that are configured using the `ManagedServiceIdentity` authentication type. The Logic Apps runtime only supports the `Raw`
9+
and `ActiveDirectoryOAuth` authentication types when running in a local developer environment. [[Issue #30](https://github.com/LogicAppUnit/TestingFramework/issues/30)]
10+
- The `testConfiguration.json` file is now optional. If the file does not exist, or contains an empty JSON document (`{}`), the default values are used for all settings. Previous versions of the framework would fail a test if the configuration file did not exist. [[Issue #28](https://github.com/LogicAppUnit/TestingFramework/issues/28)]
11+
- `Call a local function` actions are now mocked using HTTP actions. This means that the dependencies between a workflow and a .NET Framework function can be broken to enable better unit testing of the workflow.
12+
- Added `IMockResponseBuilder.ThrowsException(Exception exceptionToThrow)` to simulate an exception being thrown by a local .NET Framework function.
13+
- Fixed a typo in the name of the `logging.writeFunctionRuntimeStartupLogs` configuration setting. Previously the setting was named `logging.writeFunctionRuntineStartupLogs` (note the incorrect spelling `Runtine`). [[PR #29](https://github.com/LogicAppUnit/TestingFramework/pull/29), [@jeanpaulsmit](https://github.com/jeanpaulsmit)] <br /> :warning: ***This is a breaking change. Any use of the `writeFunctionRuntineStartupLogs` setting in the `testConfiguration.json` file will need to be updated.***
14+
15+
LogicAppUnit.Samples.LogicApps.Tests:
16+
17+
- Added a `call-local-function-workflow` workflow and unit tests to demonstrate the mocking of a local .NET Framework function.
18+
19+
120
# 1.8.0 (24th October 2023)
221

322
LogicAppUnit Testing Framework:
423

5-
- Added new methods `TestRunner.WorkflowWasTerminated`, `TestRunner.WorkflowTerminationCode` and `TestRunner.WorkflowTerminationMessage` to allow the effects of a `Terminate` action in a workflow to be tested.
24+
- Added new properties `TestRunner.WorkflowWasTerminated`, `TestRunner.WorkflowTerminationCode` and `TestRunner.WorkflowTerminationMessage` to allow the effects of a _Terminate_ action in a workflow to be tested.
625
- Mock responses can be configured using the fluent API in the test class initialization method, using the `WorkflowTestBase.AddMockResponse()` method. Mock responses configured using this method will be used by every test runner that is created in the same test class, and have a lower priority compared to the mock responses created using `ITestRunner.AddMockResponse()` and `ITestRunner.AddApiMocks`. This feature removes the need to repeatedly configure the same mocked responses in multiple tests in a test class.
726
- The HTTP status code for the default mock response can now be set in the `testConfiguration.json` file using the `runner.defaultHttpResponseStatusCode` option. Previously the status code was hard-coded to HTTP 200 (OK). The default value for this option is HTTP 200 (OK) to ensure backwards compatibility.
827
- Added a new feature to remove the chunking configuration for HTTP actions (`runtimeConfiguration.contentTransfer.transferMode`). This feature is enabled/disabled in the `testConfiguration.json` file using the `workflow.removeHttpChunkingConfiguration` option. The default value for this option is `true`. [[Issue #24](https://github.com/LogicAppUnit/TestingFramework/issues/24)]

License.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 LogicAppUnit
3+
Copyright (c) 2024 LogicAppUnit
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
Binary file not shown.

LogicAppUnit.Samples.LogicApps/.gitignore

Lines changed: 0 additions & 6 deletions
This file was deleted.

LogicAppUnit.Samples.LogicApps/.vscode/launch.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The testing framework has been designed to make it easier to perform isolated un
1616
- Replace non-HTTP triggers with HTTP triggers to enable automated testing of every workflow, irrespective of the trigger type.
1717
- Remove external service dependencies for built-in service provider connectors by replacing these actions with HTTP actions and a mock HTTP server that is managed by the framework.
1818
- Remove external service dependencies for managed API connectors by automatically re-configuring managed API connections to use a mock HTTP server that is managed by the framework.
19-
- Remove dependencies on invoked workflows by replacing the Invoke Workflow actions with HTTP actions and a mock HTTP server that is managed by the framework.
19+
- Remove dependencies on invoked workflows and called local functions by replacing the Invoke Workflow and Call Local Function actions with HTTP actions and a mock HTTP server that is managed by the framework.
2020
- Remove all retry policies to ensure that tests exercising failure scenarios do not take a long time to execute.
2121
- A fluent API to configure request matching and the creation of responses for the mock HTTP server.
2222
- Detailed test execution logging to help with workflow test authoring and debugging.
@@ -27,13 +27,14 @@ The testing framework has been designed to make it easier to perform isolated un
2727

2828
## Projects
2929

30-
This code repository includes three projects:
30+
This code repository includes four projects:
3131

3232
| Name | Description |
3333
|:-----|:------------|
3434
| LogicAppUnit | The testing framework. |
35-
| LogicAppUnit.Samples.LogicApps.Tests | Sample test project that demonstrates the features of the testing framework.
35+
| LogicAppUnit.Samples.LogicApps.Tests | Test project that demonstrates the features of the testing framework.
3636
| LogicAppUnit.Samples.LogicApps | Workflows that are tested by the sample test project. |
37+
| LogicAppUnit.Samples.Functions | Local .NET Framework functions that are called by workflows. |
3738

3839

3940
## Packages
@@ -52,6 +53,10 @@ The framework has been tested with these environments:
5253
- MacOS
5354

5455

56+
## Give a Star :star:
57+
If you like or are using this project please give it a star. Thanks.
58+
59+
5560
## Main Contributors
5661

5762
- [Mark Abrams](https://github.com/mark-abrams)
@@ -69,7 +74,5 @@ The best way to understand how the framework works and how to write tests using
6974
This is a list of possible future improvements and changes for the framework. Please create a [new issue](https://github.com/LogicAppUnit/TestingFramework/issues) if there are other features that you would like to see.
7075

7176
- Add more features to the fluent API for request matching and the creation of mock responses.
72-
- Add a feature to the fluent API to allow a mock response to be matched using just the name of the workflow action that created the request. This would make it easier to match the request, compared to using multiple properties of the request such as the HTTP method, URI path and/or request content.
7377
- Add a `Verifiable()` feature to the fluent API so that a test case can assert that a test execution did send a request to the mock HTTP server that was successfully matched. This would work in a simialar way to the `Verifiable()` feature in the [moq](https://github.com/devlooped/moq) unit testing framework.
74-
- Support the `Call a local function` action when calling a .NET Framework function from a Logic App workflow.
7578
- Auto-generate C# test cases based on a workflow's run history in the local development environment.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"ms-azuretools.vscode-azurefunctions",
4+
"ms-dotnettools.csharp"
5+
]
6+
}

0 commit comments

Comments
 (0)