Skip to content

Add Test projects to the solution #27

Open
@grantcolley

Description

@grantcolley

bUnit for testing Blazor components
AutoFixture for generating fake test data

// Install bUnit
dotnet new --install bunit.template

// Install the latest bUnit project template
dotnet new --install bunit.template::1.2.49

// Navigate to the solution folder and create a test project
dotnet new bunit -o ProjectName.Tests 

// Add the test project to the solution
dotnet sln add ProjectName.Tests/ProjectName.Tests.csproj

// Add a package reference for AutoFixture
<PackageReference Include="AutoFixture" Version="4.17.0" />

// Add using statements to the _Imports.razor file
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.Extensions.DependencyInjection
@using AutoFixture
@using Bunit.JSInterop.InvocationHandlers
@using MediatR

// Add a reference to the project containing the components to test

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions