Blazorme.TestHost
26.9.14
dotnet add package Blazorme.TestHost --version 26.9.14
NuGet\Install-Package Blazorme.TestHost -Version 26.9.14
<PackageReference Include="Blazorme.TestHost" Version="26.9.14" />
<PackageVersion Include="Blazorme.TestHost" Version="26.9.14" />
<PackageReference Include="Blazorme.TestHost" />
paket add Blazorme.TestHost --version 26.9.14
#r "nuget: Blazorme.TestHost, 26.9.14"
#:package Blazorme.TestHost@26.9.14
#addin nuget:?package=Blazorme.TestHost&version=26.9.14
#tool nuget:?package=Blazorme.TestHost&version=26.9.14
Blazorme.TestHost
Support library for Blazor component unit testing. The source code is taken from Steve Sanderson's BlazorUnitTestingPrototype project. See his blog post for more details. His project is available only as source code; this package makes it usable as a dependency.
Consider bUnit first
bUnit grew out of the same prototype and is the actively maintained library for this job. For a new test suite, prefer it. This package exists for projects already built on it.
Requirements
Targets net8.0 and net10.0. Earlier versions targeted netstandard2.1 and net5.0; those
are no longer supported.
.NET 8 is included deliberately. A net10.0-only package would leave every project on .NET 5 to .NET 9 resolving 1.0.0, which crashes at runtime (see below), so those users would be worse off than before.
Version 1.0.0 did not work on .NET 5 or later, despite advertising that it did. Duplicate
PackageReferenceitems meant itsnet5.0build was compiled against ASP.NET Core 3.1, whoseRenderTreeFrameexposed public fields that became properties in .NET 5. Rendering a component threwMissingFieldExceptionat runtime. Fixed in this release.
Installation
Install-Package Blazorme.TestHost
Usage
using Blazorme;
var host = new TestHost();
host.AddService<IMyService, IMyService>(myServiceStub);
var component = host.AddComponent<MyComponent>();
component.Find("button.submit")?.Click();
component.GetMarkup().Should().Contain("Saved");
Find returns null when the selector matches nothing; FindAll returns every match. Both accept
CSS selectors, resolved by Fizzler over the rendered markup.
| Product | Versions 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. |
-
net10.0
- Fizzler.Systems.HtmlAgilityPack (>= 1.2.1)
- Microsoft.AspNetCore.Components (>= 10.0.12)
- Microsoft.AspNetCore.Components.Web (>= 10.0.12)
- Microsoft.Extensions.DependencyInjection (>= 10.0.12)
- Microsoft.Extensions.Logging (>= 10.0.12)
- RichardSzalay.MockHttp (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
.NET 10 only. The .NET 8 target has been dropped: ASP.NET Core 10.0.x ships no net8.0 assets, so supporting both meant pinning .NET 8 projects to ASP.NET Core 8 indefinitely, and .NET 8 leaves support in November 2026. Projects still on .NET 8 should stay on 26.9.7, which remains available and carries a net8.0 build.