Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Test projects to the solution #27

Open
grantcolley opened this issue Oct 28, 2021 · 0 comments
Open

Add Test projects to the solution #27

grantcolley opened this issue Oct 28, 2021 · 0 comments
Assignees
Labels
unittest Write unit test

Comments

@grantcolley
Copy link
Owner

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
@grantcolley grantcolley added the feature New feature label Oct 28, 2021
@grantcolley grantcolley self-assigned this Oct 28, 2021
@grantcolley grantcolley added unittest Write unit test and removed feature New feature labels Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
unittest Write unit test
Projects
None yet
Development

No branches or pull requests

1 participant