Skip to content

UUF: Test Min API: Clarify testing framework & prereq #36046

@wadepickett

Description

@wadepickett

Description

User feedback transferred from UUF System:

"it it xunit or nunit or what?where to get MockDb(), what nuget?"

Problem Statement

The current article on testing Minimal API apps shows code samples using testing frameworks and mock databases, but doesn't specify:

  1. Which testing framework is being used (xUnit, NUnit, MSTest, etc.)
  2. How to implement or obtain the MockDb() functionality shown in examples
  3. Which NuGet packages are required for the testing approach shown

This makes it difficult for readers who are new to testing or unfamiliar with the specific approach to implement the examples in their own projects.

[The following is AI assisted, review carefully]

Proposed Solution

The article should be updated to include:

  1. A clear statement of which testing framework is used in the examples (appears to be xUnit based on the code style)
  2. Information about the NuGet packages needed for both the testing framework and any mocking libraries
  3. Brief explanation or link to the implementation of MockDb() or a more complete example showing how database mocking is set up

Specific Changes Needed

  1. Add a section near the beginning of the article that explains the testing setup:

Testing setup

The examples in this article use xUnit as the testing framework. To follow along, you'll need to add the following NuGet packages to your test project:

<ItemGroup>
  <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
  <PackageReference Include="xunit" Version="2.4.2" />
  <PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
  <!-- Add any other packages needed for mocking or testing -->
</ItemGroup>

For database mocking, the examples use a simple in-memory implementation. The full implementation of the MockDb() method and related classes can be found in the sample repository.

  1. Update the code sample sections to include more context about the testing approach used.

  2. Consider adding a link to a complete, simple example that shows a minimal implementation of the MockDb() functionality for readers who don't want to dig through the full sample repository.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/test-min-api?view=aspnetcore-9.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/minimal-apis/test-min-api.md

Document ID

9487a919-5254-627c-d5cf-169d99a7e51b

Platform Id

240a9ed9-e999-c73a-6bd5-e7354789d67b

Article author

@wadepickett

Metadata

  • ID: 9487a919-5254-627c-d5cf-169d99a7e51b
  • PlatformId: 240a9ed9-e999-c73a-6bd5-e7354789d67b
  • Service: aspnet-core
  • Sub-service: fundamentals

Related Issues


Associated WorkItem - 488031

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions