Repository navigation
Conversation
Add caller-owned HttpClient support for Functions webhooks, shared Functions fixtures and framework factories, updated documentation, and build-output cleanup tooling. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Public API signature changes can break previously compiled consumers, and unchecked configuration paths allow the cleanup script to recursively delete project source files.
3 open issues
What changed in this PR
This PR extends Azure Functions testing with standalone webhook clients and framework-neutral fixtures, packaged as version 6.1.0.
Changes:
- Adds webhook support using a caller-owned
HttpClient, without launching Aspire. - Adds
WithFunctionTester<TEntryPoint>and optional test-framework factories, with lifecycle and ownership tests. - Updates documentation and release metadata, and adds a build-output cleanup script.
| File | Description |
|---|---|
| tests/UnitTestEx.Xunit.Test/WithFunctionTesterTest.cs | Tests explicit xUnit factories, assertions, and output capture. |
| tests/UnitTestEx.NUnit.Test/WithFunctionTesterTest.cs | Tests tester reuse, configuration, factory failures, and disposal. |
| tests/UnitTestEx.Aspire.NUnit.Test/FunctionsWebhookClientTest.cs | Tests webhook payloads, headers, ownership, and failure handling. |
| src/UnitTestEx.Azure.Functions/WithFunctionTester.cs | Adds the shared, disposable Functions fixture base. |
| src/UnitTestEx.Azure.Functions/FunctionTester.cs | Adds an optional framework factory to tester creation. |
| src/UnitTestEx.Azure.Functions/Azure/Functions/FunctionTesterT.cs | Adds constructor factory support and corrects the summary comment. |
| src/UnitTestEx.Aspire/Aspire/FunctionsWebhookClient.cs | Supports caller-owned HTTP clients while preserving Aspire client disposal. |
| docs/azure-functions.md | Documents fixture lifetimes, disposal, and framework factories. |
| docs/aspire.md | Documents standalone webhook usage and client ownership. |
| Common.targets | Sets the shared package version to 6.1.0. |
| clean-build-outputs.ps1 | Adds configurable cleanup with preview and build-server shutdown options. |
| CHANGELOG.md | Records the new 6.1.0 testing features. |
Review effort: Balanced
Comment on lines
+51
to
+52
| $path = Join-Path $_.FullName $config | ||
| if (Test-Path -LiteralPath $path) { Get-Item -LiteralPath $path } |
| /// <param name="createFactory">The optional function to create the <see cref="TestFrameworkImplementor"/> instance.</param> | ||
| public class FunctionTester<TEntryPoint>(bool? includeUnitTestConfiguration, bool? includeUserSecrets, IEnumerable<KeyValuePair<string, string?>>? additionalConfiguration, Func<TestFrameworkImplementor>? createFactory = null) | ||
| : FunctionTesterBase<TEntryPoint, FunctionTester<TEntryPoint>>(TestFrameworkImplementor.Create(createFactory), includeUnitTestConfiguration, includeUserSecrets, additionalConfiguration) where TEntryPoint : class | ||
| { } |
| /// <param name="createFactory">The optional function to create the <see cref="TestFrameworkImplementor"/> instance.</param> | ||
| /// <returns>The <see cref="FunctionTester{TEntryPoint}"/>.</returns> | ||
| public static FunctionTester<TEntryPoint> Create<TEntryPoint>(bool? includeUnitTestConfiguration = null, bool? includeUserSecrets = null, IEnumerable<KeyValuePair<string, string?>>? additionalConfiguration = null) | ||
| public static FunctionTester<TEntryPoint> Create<TEntryPoint>(bool? includeUnitTestConfiguration = null, bool? includeUserSecrets = null, IEnumerable<KeyValuePair<string, string?>>? additionalConfiguration = null, Func<TestFrameworkImplementor>? createFactory = null) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
FunctionsWebhookClient(HttpClient)so runners can reuse webhook serialization and notification headers without launching an Aspire fixture. The caller retains ownership of the supplied client and returned responses; Aspire-created clients retain their existing per-request disposal behavior.WithFunctionTester<TEntryPoint>with fixture-level disposal and optional test-framework factories on the fixture,FunctionTester.Create, and concrete tester constructor.Validation
WithFunctionTesterTestNUnit tests: 9 passed on each of .NET 8, 9, and 10.WithFunctionTesterTestxUnit tests: 2 passed on each of .NET 8, 9, and 10.FunctionsWebhookClientTesttests: 6 passed on each of .NET 8, 9, and 10, covering request payloads/headers, repeated calls, ownership, failure, cancellation, and null arguments.git diff --checkpasses. Existing ASPIRE010 CLI-bundle configuration warnings remain.