liveBook · Manning

Test automation framework

As explained in ASP.NET Core in Action, 3e

A testing framework is a software framework that provides conventions, APIs, and execution support for automated tests.

A test automation framework supplies conventions, APIs, and execution support for automated tests. It lets you run a suite instead of manually checking each scenario, while keeping test code separate from application logic. section 35.0

A .NET test project combines several pieces:

  • The .NET Test SDK identifies and supports test projects. section 35.2
  • A framework such as xUnit, MSTest, or NUnit provides test conventions and assertion helpers. section 35.0 section 35.7
  • A runner adapter connects the framework to Visual Studio Test Explorer or the dotnet test command. section 35.7

A small xUnit test

A [Fact] method follows Arrange, Act, Assert: create a CurrencyConverter, call ConvertToGbp with value 3 and rate 1.5, then use Assert.Equal to verify the expected result of 2. A [Theory] adds several [InlineData] sets, creating separate runs without duplicating the test method. section 35.5

Figure 35.1 The New Project dialog box in Visual Studio. Choose xUnit Test Project to create an xUnit project, or choose Unit Test Project to create an MSTest project.
CH35_F01_Lock3

Use the Visual Studio project dialog to create an xUnit test project; the equivalent CLI command is dotnet new xunit. section 35.2

Good tests verify observable behavior, including failure conditions. Assert.Throws checks that invalid input raises the expected exception type, while avoiding dependence on internal implementation details that could make tests brittle. section 35.6

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains project components, test attributes, assertions, parameterized runs, and exception checks, but defers ASP.NET Core integration testing.
Examples
Uses CurrencyConverter tests covering expected conversions, multiple InlineData cases, and zero-rate ArgumentException behavior.
What it assumes
Assumes basic C# and .NET project familiarity while introducing unit-test terminology, project structure, and assertion mechanics.
What you can do after
Build and run an xUnit test project, write Fact and Theory tests, assert results, and verify expected exceptions.
How it connects
Connects unit testing with xUnit, MSTest, NUnit, assertions, the .NET Test SDK, test runners, and integration testing.

Also explained in

Compare how 4 books explain test automation framework →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.