Skip to content

Commit 253eef3

Browse files
committed
feat: Add support for custom configuration files in test projects
- Add optional parameters to Initialize() for custom config filenames: * localSettingsFilename: Custom local settings file * testProjectPath: Path to test project directory * parametersFilename: Custom parameters file * connectionsFilename: Custom connections file - Configuration file resolution precedence: * Initialize() parameter → testConfiguration.json → default * Custom files search test project first, then Logic App project * Custom files are copied to standard names for Logic App runtime - Consolidate duplicate file processing logic: * Created ProcessConfigurationFile() helper method * Enhanced ResolveConfigurationFilePath() to return tuple with source info * Reduced code duplication by ~60% in file processing section - Fix testConfiguration.json structure: * Move localSettingsFilename to root level (not inside workflow section) * Ensures proper configuration loading for default test behavior - Copy behavior: * Custom files from test project are copied to testConfiguration.json
1 parent ccc971a commit 253eef3

8 files changed

Lines changed: 137 additions & 64 deletions

File tree

ChangeLog.md

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,23 @@
22

33
LogicAppUnit Testing Framework:
44

5-
- Added support for custom configuration files in test projects. The `Initialize()` method now accepts optional parameters to specify custom filenames for `local.settings.json`, `parameters.json`, and `connections.json`. Configuration files are resolved by checking the test project directory first, then falling back to the Logic App project directory. This allows tests to use test-specific configurations that override the Logic App project defaults. This enables unified test suites across environments - use the same test code for DEV, QA, and PROD by simply swapping configuration files (e.g., `parameters-dev.json`, `parameters-qa.json`, `parameters-prod.json`).
5+
- Added support for custom configuration files in test projects. The `Initialize()` method now accepts optional parameters to specify custom filenames for `local.settings.json`, `parameters.json`, and `connections.json`. Configuration files are resolved by checking the test project directory first, then falling back to the Logic App project directory. When custom-named configuration files are found in the test project, they are automatically copied to the Logic App directory with standard filenames (`parameters.json`, `connections.json`) to ensure the Logic App runtime uses the correct test-specific configurations. This allows tests to use test-specific configurations that override the Logic App project defaults. This enables unified test suites across environments - use the same test code for DEV, QA, and PROD by simply swapping configuration files (e.g., `parameters-dev.json`, `parameters-qa.json`, `parameters-prod.json`).
66

77
LogicAppUnit.Samples.LogicApps.Tests:
88

99
- Added example custom configuration files (`local.settings-custom.json`, `parameters-custom.json`, `connections-custom.json`) in the test project.
10-
- Added `HttpWorkflowCustomConfigTest`, `BuiltInConnectorWorkflowCustomConfigTest`, and `ManagedApiConnectorWorkflowCustomConfigTest` to demonstrate the custom configuration file feature.
11-
10+
- Added `HttpWorkflowCustomConfigTest` and `ManagedApiConnectorWorkflowCustomConfigTest` to demonstrate the custom configuration file feature.
1211

1312
# 1.12.0 (18th July 2025)
1413

1514
LogicAppUnit Testing Framework:
1615

1716
- HTTP actions with the authentication type set to `ManagedServiceIdentity` are updated to use the `None` authentication type. [[Issue #49](https://github.com/LogicAppUnit/TestingFramework/issues/49)], [[Issue #50](https://github.com/LogicAppUnit/TestingFramework/issues/50)] and [[PR #51](https://github.com/LogicAppUnit/TestingFramework/pull/51), [@ronaldbosma ](https://github.com/ronaldbosma)]
1817

19-
2018
LogicAppUnit.Samples.LogicApps.Tests:
2119

2220
- Added a `http-with-managed-identity-workflow` workflow and unit test to test a workflow that includes a HTTP action with the authentication type set to `ManagedServiceIdentity`.
2321

24-
2522
# 1.11.0 (11th April 2025)
2623

2724
LogicAppUnit Testing Framework:
@@ -32,7 +29,6 @@ LogicAppUnit Testing Framework:
3229
- Updated method `ContentHelper.FormatJson()` to use `JToken.Parse()` instead of `JObject.Parse()`. [[Issue #45](https://github.com/LogicAppUnit/TestingFramework/issues/45)]
3330
- Added new property `TestRunner.WorkflowTerminationCodeAsString` that returns the workflow termination code as a string value. The existing property `TestRunner.WorkflowTerminationCode` returns the code as an integer value, but the code is defined as a string data type in the workflow schema reference documentation. [[Issue #46](https://github.com/LogicAppUnit/TestingFramework/issues/46)]
3431

35-
3632
# 1.10.0 (4th November 2024)
3733

3834
LogicAppUnit Testing Framework:
@@ -45,7 +41,6 @@ LogicAppUnit.Samples.LogicApps.Tests:
4541
- Added a `call-data-mapper-workflow` workflow and unit tests to test workflows that call the data mapper.
4642
- Added a `inline-script-workflow` workflow and unit tests to test workflows that call in-line C# script (.csx) files.
4743

48-
4944
# 1.9.0 (23rd January 2024)
5045

5146
LogicAppUnit Testing Framework:
@@ -54,17 +49,16 @@ LogicAppUnit Testing Framework:
5449
- 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.
5550
- 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.
5651
- 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`
57-
and `ActiveDirectoryOAuth` authentication types when running in a local developer environment. [[Issue #30](https://github.com/LogicAppUnit/TestingFramework/issues/30)]
58-
- 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)]
59-
- `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.
60-
- Added `IMockResponseBuilder.ThrowsException(Exception exceptionToThrow)` to simulate an exception being thrown by a local .NET Framework function.
61-
- 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.***
52+
and `ActiveDirectoryOAuth` authentication types when running in a local developer environment. [[Issue #30](https://github.com/LogicAppUnit/TestingFramework/issues/30)]
53+
- 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)]
54+
- `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.
55+
- Added `IMockResponseBuilder.ThrowsException(Exception exceptionToThrow)` to simulate an exception being thrown by a local .NET Framework function.
56+
- 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._**
6257

6358
LogicAppUnit.Samples.LogicApps.Tests:
6459

6560
- Added a `call-local-function-workflow` workflow and unit tests to demonstrate the mocking of a local .NET Framework function.
6661

67-
6862
# 1.8.0 (24th October 2023)
6963

7064
LogicAppUnit Testing Framework:
@@ -75,12 +69,11 @@ LogicAppUnit Testing Framework:
7569
- 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)]
7670
- Added `IMockResponseBuilder.WithAccepted()` as a short-cut when creating a response with a HTTP 202 (Accepted) status code.
7771

78-
7972
# 1.7.0 (27th July 2023)
8073

8174
LogicAppUnit Testing Framework:
8275

83-
- Mock responses can be configured using `ITestRunner.AddMockResponse()` and a fluent API, this includes the definition of the request matching conditions and the response.
76+
- Mock responses can be configured using `ITestRunner.AddMockResponse()` and a fluent API, this includes the definition of the request matching conditions and the response.
8477
- Removed public methods `ContentHelper.SerializeObject()`, `ContentHelper.DeserializeObject()` and `ContentHelper.JClone()`, these were for internal use only and are now obsolete.
8578
- Include the LogicAppUnit version at the end of the test log.
8679
- The maximum execution time for a workflow can now be set in the `testConfiguration.json` file using the `runner.maxWorkflowExecutionDuration` option. Previously this duration was hard-coded to 5 minutes. The default value for this option is 300 seconds (5 minutes).
@@ -90,7 +83,6 @@ LogicAppUnit.Samples.LogicApps.Tests:
9083

9184
- Added a `fluent-workflow` workflow and unit tests to demonstrate the use of the fluent API.
9285

93-
9486
# 1.6.0 (5th June 2023)
9587

9688
LogicAppUnit Testing Framework:
@@ -101,13 +93,12 @@ LogicAppUnit Testing Framework:
10193
- Added support for workflows using a HTTP trigger where the response action is not the last action in the workflow. Previous versions of the framework assumed that the workflow was complete once the response was received. Now the framework polls the workflow status to ensure that the workflow has completed. [[PR #15](https://github.com/LogicAppUnit/TestingFramework/pull/15), [@atthevergeof](https://github.com/atthevergeof)]
10294
- Fixed a bug in `TestRunner.TriggerWorkflow()` where the return value was being incorrectly set to the (disposed) workflow run history API response. The response is now correctly set to the workflow trigger API response. This bug only occurred for workflows that have a non-HTTP trigger (which is then replaced by a HTTP trigger by the framework).
10395
<br />
104-
:warning: ***This is a breaking change. Previously the status code for the response would have been HTTP 200 (OK), now it will be HTTP 202 (Accepted).***
96+
:warning: **_This is a breaking change. Previously the status code for the response would have been HTTP 200 (OK), now it will be HTTP 202 (Accepted)._**
10597

10698
LogicAppUnit.Samples.LogicApps.Tests:
10799

108100
- Added a `http-async-workflow` workflow and unit tests to demonstrate the use of the testing framework with HTTP triggers and asynchronous responses.
109101

110-
111102
# 1.5.0 (14th April 2023)
112103

113104
LogicAppUnit Testing Framework:
@@ -121,14 +112,12 @@ LogicAppUnit.Samples.LogicApps.Tests:
121112

122113
- Added an `invoke-workflow` workflow and unit tests to demonstrate the use of the testing framework with child workflows that are invoked from a parent workflow.
123114

124-
125115
# 1.4.0 (21st February 2023)
126116

127117
LogicAppUnit Testing Framework:
128118

129119
- Changed the logic that updates the `connectionRuntimeUrl` for Managed API connectors so that it works with URL values that include `@appsetting()` references. [[Issue #9](https://github.com/LogicAppUnit/TestingFramework/issues/9)]
130120

131-
132121
# 1.3.0 (1st February 2023)
133122

134123
LogicAppUnit Testing Framework:
@@ -141,7 +130,6 @@ LogicAppUnit.Samples.LogicApps.Tests:
141130

142131
- Updated the `http-workflow` workflow and unit tests to include tracked properties.
143132

144-
145133
# 1.2.0 (9th January 2023)
146134

147135
LogicAppUnit Testing Framework:
@@ -155,7 +143,6 @@ LogicAppUnit.Samples.LogicApps.Tests:
155143

156144
- Added a `loop-workflow` workflow and unit tests to demonstrate the use of the testing framework with a workflow containing actions in an `Until` loop and a `ForEach` loop.
157145

158-
159146
# 1.1.0 (16th December 2022)
160147

161148
LogicAppUnit Testing Framework:
@@ -174,7 +161,6 @@ LogicAppUnit.Samples.LogicApps.Tests:
174161

175162
- Added a `stateless-workflow` workflow and unit tests to demonstrate the use of the testing framework with a stateless workflow, a custom client tracking id and a relative path configured in the HTTP trigger.
176163

177-
178164
# 1.0.0 (9th December 2022)
179165

180166
- Initial version.

src/LogicAppUnit.Samples.LogicApps.Tests/HttpWorkflow/HttpWorkflowCustomConfigTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public void TestInitialize()
2929
Constants.LOGIC_APP_TEST_EXAMPLE_BASE_PATH,
3030
Constants.HTTP_WORKFLOW,
3131
localSettingsFilename: "local.settings-custom.json",
32-
parametersFilename: "parameters-custom.json"
32+
parametersFilename: "parameters-custom.json",
33+
connectionsFilename: "connections-custom.json"
3334
);
3435
}
3536

src/LogicAppUnit.Samples.LogicApps.Tests/ManagedApiConnectorWorkflow/ManagedApiConnectorWorkflowCustomConfigTest.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ public void TestInitialize()
2525
Constants.LOGIC_APP_TEST_EXAMPLE_BASE_PATH,
2626
Constants.MANAGED_API_CONNECTOR_WORKFLOW,
2727
localSettingsFilename: "local.settings-custom.json",
28-
parametersFilename: "parameters-custom.json",
29-
connectionsFilename: "connections-custom.json"
28+
parametersFilename: "parameters-custom.json"
3029
);
3130
}
3231

src/LogicAppUnit.Samples.LogicApps.Tests/local.settings-custom.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
"Outlook-ConnectionRuntimeUrl": "https://7606763fdc09952f.10.common.logic-uksouth.azure-apihub.net/apim/outlook/79a0bc680716416e90e17323b581695d/",
1515
"Salesforce-ConnectionKey": "any-salesforce-connection-key",
1616
"Salesforce-ConnectionRuntimeUrl": "https://7606763fdc09952f.10.common.logic-uksouth.azure-apihub.net/apim/salesforce/fba515601ef14f9193eee596a9dcfd1c/",
17-
"ServiceOne-Url": "https://external-service-one.testing.net/api/v1",
17+
"ServiceOne-Url": "https://external-service-one1.testing.net/api/v1",
1818
"ServiceOne-Authentication-APIKey": "serviceone-auth-apikey",
1919
"ServiceOne-Authentication-WebHook-APIKey": "serviceone-auth-webhook-apikey",
2020
"ServiceTwo-Url": "https://external-service-two.testing.net/api/v1.1",
2121
"ServiceTwo-Verison2Url": "https://external-service-two.testing.net/api/v2.0",
2222
"ServiceTwo-Authentication-APIKey": "servicetwo-auth-apikey",
2323
"ServiceTwo-DefaultAddressType": "business",
24-
"Sql_ConnectionString": "any-sql-connection-string",
25-
"ServiceBus_ConnectionString": "any-servicebus-connection-string"
24+
"Sql_ConnectionString": "any-sql-connection-string-custom",
25+
"ServiceBus_ConnectionString": "any-servicebus-connection-custom-string"
2626
}
2727
}

src/LogicAppUnit.Samples.LogicApps.Tests/testConfiguration.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"workflow": {
88
"externalApiUrlsToMock": [
99
"https://external-service-one.testing.net",
10-
"https://external-service-two.testing.net"
10+
"https://external-service-two.testing.net",
11+
"https://external-service-one1.testing.net"
12+
1113
],
1214
"builtInConnectorsToMock": [
1315
"executeQuery",
@@ -18,5 +20,7 @@
1820
"CreateOrUpdateDocument"
1921
],
2022
"autoConfigureWithStatelessRunHistory": true
21-
}
23+
},
24+
25+
"localSettingsFilename": "local.settings.dev.json"
2226
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"IsEncrypted": false,
3+
"Values": {
4+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
5+
"APP_KIND": "workflowapp",
6+
"FUNCTIONS_WORKER_RUNTIME": "node",
7+
"WORKFLOWS_SUBSCRIPTION_ID": "c1661296-a732-44b9-8458-d1a0dd19815e",
8+
"WORKFLOWS_LOCATION_NAME": "uksouth",
9+
"WORKFLOWS_RESOURCE_GROUP_NAME": "rg-uks-01",
10+
"AzureBlob-ConnectionString": "any-blob-connection-string",
11+
"AzureQueue-ConnectionString": "any-queue-connection-string",
12+
"Outlook-ConnectionKey": "any-outlook-connection-key",
13+
"Outlook-SubjectPrefix": "INFORMATION",
14+
"Outlook-ConnectionRuntimeUrl": "https://7606763fdc09952f.10.common.logic-uksouth.azure-apihub.net/apim/outlook/79a0bc680716416e90e17323b581695d/",
15+
"Salesforce-ConnectionKey": "any-salesforce-connection-key",
16+
"Salesforce-ConnectionRuntimeUrl": "https://7606763fdc09952f.10.common.logic-uksouth.azure-apihub.net/apim/salesforce/fba515601ef14f9193eee596a9dcfd1c/",
17+
"ServiceOne-Url": "https://external-service-one1.testing.net/api/v1",
18+
"ServiceOne-Authentication-APIKey": "serviceone-auth-apikey",
19+
"ServiceOne-Authentication-WebHook-APIKey": "serviceone-auth-webhook-apikey",
20+
"ServiceTwo-Url": "https://external-service-two.testing.net/api/v1.1",
21+
"ServiceTwo-Verison2Url": "https://external-service-two.testing.net/api/v2.0",
22+
"ServiceTwo-Authentication-APIKey": "servicetwo-auth-apikey",
23+
"ServiceTwo-DefaultAddressType": "business",
24+
"Sql_ConnectionString": "any-sql-connection-string-custom",
25+
"ServiceBus_ConnectionString": "any-servicebus-connection-custom-string"
26+
}
27+
}

src/LogicAppUnit.Samples.LogicApps/local.settings.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
"Outlook-ConnectionRuntimeUrl": "https://7606763fdc09952f.10.common.logic-uksouth.azure-apihub.net/apim/outlook/79a0bc680716416e90e17323b581695d/",
1515
"Salesforce-ConnectionKey": "any-salesforce-connection-key",
1616
"Salesforce-ConnectionRuntimeUrl": "https://7606763fdc09952f.10.common.logic-uksouth.azure-apihub.net/apim/salesforce/fba515601ef14f9193eee596a9dcfd1c/",
17-
"ServiceOne-Url": "https://external-service-one.testing.net/api/v1",
17+
"ServiceOne-Url": "https://external-service-one1.testing.net/api/v1",
1818
"ServiceOne-Authentication-APIKey": "serviceone-auth-apikey",
1919
"ServiceOne-Authentication-WebHook-APIKey": "serviceone-auth-webhook-apikey",
2020
"ServiceTwo-Url": "https://external-service-two.testing.net/api/v1.1",
2121
"ServiceTwo-Verison2Url": "https://external-service-two.testing.net/api/v2.0",
2222
"ServiceTwo-Authentication-APIKey": "servicetwo-auth-apikey",
2323
"ServiceTwo-DefaultAddressType": "business",
24-
"Sql_ConnectionString": "any-sql-connection-string",
25-
"ServiceBus_ConnectionString": "any-servicebus-connection-string"
24+
"Sql_ConnectionString": "any-sql-connection-string-custom",
25+
"ServiceBus_ConnectionString": "any-servicebus-connection-custom-string"
2626
}
2727
}

0 commit comments

Comments
 (0)