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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CasCap.Common.Testing" Version="4.16.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CasCap.Common.Testing" Version="4.16.0" />
                    
Directory.Packages.props
<PackageReference Include="CasCap.Common.Testing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CasCap.Common.Testing --version 4.16.0
                    
#r "nuget: CasCap.Common.Testing, 4.16.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CasCap.Common.Testing@4.16.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CasCap.Common.Testing&version=4.16.0
                    
Install as a Cake Addin
#tool nuget:?package=CasCap.Common.Testing&version=4.16.0
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed