CasCap.Common.Testing
4.16.0
Prefix Reserved
dotnet add package CasCap.Common.Testing --version 4.16.0
NuGet\Install-Package CasCap.Common.Testing -Version 4.16.0
<PackageReference Include="CasCap.Common.Testing" Version="4.16.0" />
<PackageVersion Include="CasCap.Common.Testing" Version="4.16.0" />
<PackageReference Include="CasCap.Common.Testing" />
paket add CasCap.Common.Testing --version 4.16.0
#r "nuget: CasCap.Common.Testing, 4.16.0"
#:package CasCap.Common.Testing@4.16.0
#addin nuget:?package=CasCap.Common.Testing&version=4.16.0
#tool nuget:?package=CasCap.Common.Testing&version=4.16.0
CasCap.Common.Testing
xUnit v3 helpers for routing .NET logs to test output, stubbing HTTP responses, creating temporary files and conditionally skipping tests in CI.
Installation
dotnet add package CasCap.Common.Testing
Target frameworks: net8.0, net9.0, net10.0
Usage
Capture Application Logs
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Xunit;
public sealed class LoggingTests(ITestOutputHelper output)
{
[Fact]
public void CapturesLogs()
{
var services = new ServiceCollection();
services.AddXUnitLogging(output);
using var provider = services.BuildServiceProvider();
var logger = provider.GetRequiredService<ILogger<LoggingTests>>();
logger.LogInformation("Test logging is connected");
Assert.IsType<TestLogProvider>(
provider.GetRequiredService<ILoggerProvider>());
}
}
AddXUnitLogging installs TestLogProvider at Trace level and connects the static
ApplicationLogging factory. That static factory is process-wide; tests must account for sharing it.
Stub HTTP Without a Network
using System.Net;
using System.Net.Http;
using CasCap.Common.Xunit;
using var handler = new StubHttpMessageHandler(_ =>
new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent("example")
});
using var client = new HttpClient(handler);
var response = await client.GetStringAsync("https://example.com/resource");
The handler accepts synchronous or asynchronous response factories. Return a fresh response for
each request. It can also be assigned as a DelegatingHandler.InnerHandler.
Temporary Files
TempFile.Create() creates an empty file. CreateAsync accepts text or bytes plus a cancellation
token. Both expose the generated Path; disposing the helper attempts to delete the file.
using CasCap.Common.Xunit;
using var file = TempFile.Create(".json");
Conditional CI Skips
| Attribute | Description |
|---|---|
SkipIfCIBuildFactAttribute |
Skips the [Fact] on Azure DevOps or GitHub Actions |
SkipIfCIBuildTheoryAttribute |
Skips the [Theory] on Azure DevOps or GitHub Actions |
SkipIfGithubActionsBuildFactAttribute |
Skips the [Fact] when running on GitHub Actions |
SkipIfGithubActionsBuildTheoryAttribute |
Skips the [Theory] when running on GitHub Actions |
SkipIfAzureDevOpsBuildFactAttribute |
Skips the [Fact] when running on Azure DevOps |
SkipIfAzureDevOpsBuildTheoryAttribute |
Skips the [Theory] when running on Azure DevOps |
These attributes live in CasCap.Common.Xunit. Their environment checks target the named CI
systems; they are not a general detector for every CI vendor.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- CasCap.Common.Logging (>= 4.16.0)
- xunit.v3.extensibility.core (>= 4.0.2)
-
net8.0
- CasCap.Common.Logging (>= 4.16.0)
- xunit.v3.extensibility.core (>= 4.0.2)
-
net9.0
- CasCap.Common.Logging (>= 4.16.0)
- xunit.v3.extensibility.core (>= 4.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.16.0 | 0 | 10/21/2026 |
| 4.15.0 | 155 | 10/6/2026 |
| 4.14.4 | 213 | 10/4/2026 |
| 4.14.3 | 135 | 9/28/2026 |
| 4.14.2 | 208 | 9/25/2026 |
| 4.14.1 | 256 | 9/23/2026 |
| 4.14.0 | 264 | 9/19/2026 |
| 4.13.0 | 111 | 9/15/2026 |
| 4.12.8 | 178 | 9/10/2026 |
| 4.12.7 | 232 | 9/4/2026 |
| 4.12.6 | 131 | 9/1/2026 |
| 4.12.5 | 174 | 8/20/2026 |
| 4.12.4 | 188 | 8/18/2026 |
| 4.12.3 | 204 | 7/15/2026 |
| 4.12.2 | 167 | 6/26/2026 |
| 4.12.1 | 157 | 6/14/2026 |
| 4.12.0 | 149 | 6/12/2026 |
| 4.11.9 | 155 | 6/10/2026 |
| 4.11.8 | 186 | 5/27/2026 |
| 4.11.7 | 145 | 5/27/2026 |