(related tool on how to upgrade a project to .NET 8)
Setup a project for testing
Agregar > nuevo proyecto

Proyecto de prueba NUnit / xunit

Ponerle como nombre `
Esto deberia crear un proyecto nuevo con un test autogenerado

Comprobar los following Nuggets
// XUnit
xunit
xunit.runner.visualstudio
// NUnit
NUnit
NUnit.Analyzers
NUnit3TestAdapter
// general
Moq
FluentAssertions
FluentAssertions.Analyzers
// para testear ApplicationDbContext
Microsoft.EntityFrameworkCore.InMemory
Moq.EntityFrameworkCore
// en caso de querer code coverage y branch coverage
coverlet.collector
ReportGenerator
Como vamos a testear el proyecto original desde el proyecto nuevo .Tests, necesitamos añadir una referencia al mismo desde el proyecto .Tests
click derecho en proyecto .Tests > agregar > Referencia del proyecto…

Seleccionar el proyecto a testear > aceptar

Naming conventions
Name testing projects as [ProjectUnderTest].Tests
Name testing classes as [ClassNameUnderTest]Test
Name testing functions different styles:
- start with should and write the general idea
void ShouldAddTwoNumbers - start with the name of the function under test and _ and what should it do
void Sum_ShouldAddTwoNumbers - UnitUnderTest_Scenario_ExpectedOutcome
ParsePort_COM1_Returns1
Reporting (& branch coverage)
Manual reports
Open the administration console and write the following (substitute where {guid})
// cd into the test folder
// this one generates a new folder 'TestResults' generating a XML file
dotnet test --collect:"XPlat Code Coverage"
// this creates an improved HTML report
reportgenerator -reports:TestResults\{guid}\coverage.cobertura.xml -targetdir:"coveragereport" -reporttypes:Html
Integrate coverlet with visual studio
Go to Extensions menu and install the plugin Run Coverlet Report.
Then go to Tools > Options > Run Coverlet Report > Change integration type to Collector.
Then run all your tests manually (only the first time) and from then on you can start it through Tools > Run Code Coverage. This command generates a report file.