AurorisNet.Umbraco.AppHost.Testing 1.0.0-alpha.2

This is a prerelease version of AurorisNet.Umbraco.AppHost.Testing.
dotnet add package AurorisNet.Umbraco.AppHost.Testing --version 1.0.0-alpha.2
                    
NuGet\Install-Package AurorisNet.Umbraco.AppHost.Testing -Version 1.0.0-alpha.2
                    
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="AurorisNet.Umbraco.AppHost.Testing" Version="1.0.0-alpha.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AurorisNet.Umbraco.AppHost.Testing" Version="1.0.0-alpha.2" />
                    
Directory.Packages.props
<PackageReference Include="AurorisNet.Umbraco.AppHost.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 AurorisNet.Umbraco.AppHost.Testing --version 1.0.0-alpha.2
                    
#r "nuget: AurorisNet.Umbraco.AppHost.Testing, 1.0.0-alpha.2"
                    
#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 AurorisNet.Umbraco.AppHost.Testing@1.0.0-alpha.2
                    
#: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=AurorisNet.Umbraco.AppHost.Testing&version=1.0.0-alpha.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=AurorisNet.Umbraco.AppHost.Testing&version=1.0.0-alpha.2&prerelease
                    
Install as a Cake Tool

Umbraco App Host Testing

AurorisNet.Umbraco.AppHost.Testing boots an Umbraco App Host site in a test process, so a host's tests call its pages and endpoints over HTTP.

TestSite.StartAsync applies the host's own registrations, as its Program.cs does, on Kestrel at a free loopback port with a new SQLite database and instance folder, and returns once the unattended install has finished. The site signs in members and backoffice users, and hands out the endpoint clients of AurorisNet.Umbraco.AppBlocks.Testing for its own address and virtual path.

The package references no test framework. Failures throw TestSiteException.

Install

Reference the host project and this package, at the same version as AurorisNet.Umbraco.AppHost. TestSite applies the host's registrations through the library's generic methods, and a start with another version fails with a message that names the mismatch.

<ItemGroup>
  <PackageReference Include="xunit.v3" Version="4.0.3" />
  <PackageReference Include="AurorisNet.Umbraco.AppHost.Testing" Version="1.0.0-alpha.1" />
  <ProjectReference Include="..\MyHost\MyHost.csproj" />
  <Using Include="UmbracoAppHost.Testing" />
  <Using Include="AppBlocks.Testing" />
</ItemGroup>

Add public partial class Program { } to the host's Program.cs so a test can name its assembly.

await using var site = await TestSite.StartAsync(new TestSiteOptions { Application = typeof(Program).Assembly });
var member = site.CreateMember("pilot", "pilot@example.invalid", "Test pilot");
using var browser = await site.SignInMemberAsync(member);

var form = site.Forms(browser, pageKey, formKey);
Assert.True((await form.LoadAsync()).IsSuccess);
var saved = await form.CreateAsync(new { customer = "Test order" });

site.Attachments, site.Tabular, site.Reports and site.DownloadPaperReportAsync call the other AppBlocks endpoints the same way.

What the site reads from the host project

StartAsync finds the host project by walking up from the host assembly's folder in the test output to <assembly name>.csproj, or to the one project of that name under the first folder with a *.slnx, a *.sln or .git. Set TestSiteOptions.ProjectFolder when the build writes its output outside the repository, or when the host's assembly name differs from its project file's name.

From that folder the site reads appsettings.json and appsettings.<EnvironmentName>.json, imports the project's uSync export on first boot, and copies its Views/.

A host whose settings declare Kestrel:Endpoints or Urls replaces the free loopback port, and the start fails when they give more than one address. Keep those settings out of the files the test reads, or replace them through TestSiteOptions.Settings.

One site at a time

Umbraco keeps state in static fields, so a process runs one site at a time. StartAsync throws while another site of the process is running. Put every test class that starts a site in one collection that runs without parallelization.

A process installs once for each set of options and gives every site its own copy of that install. TestSiteOptions.ConfigureBuilder runs on the copy only, so a registration that the first-boot import depends on needs UseInstallSnapshot = false.

Other test runners

The host excludes assemblies whose names start with xunit. from Umbraco's type scan. For another runner, add its assembly prefixes through TestSiteOptions.Settings at an index of 10 or more, such as Umbraco:CMS:TypeFinder:AdditionalAssemblyExclusionEntries:10. A lower index replaces one of the host's own entries.

Documentation

Test a host lists every option and TestSite member, with a complete test class.

License

MIT

Product Compatible and additional computed target framework versions.
.NET 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
1.0.0-alpha.2 37 11/19/2026
1.0.0-alpha.1 44 11/18/2026