AspNetCore.Docs/aspnetcore/migration/inc/unit-testing.md

19 lines
1011 B
Markdown
Raw Normal View History

---
title: Unit Testing
description: Unit Testing
author: afshinm
ms.author: amehrabani
monikerRange: '>= aspnetcore-6.0'
2023-10-04 02:23:46 +08:00
ms.date: 10/03/2023
ms.topic: article
uid: migration/inc/unit-testing
---
# Unit Testing
2023-10-04 01:21:28 +08:00
In most cases, there's no need to set up additional components for running tests. But if the component being tested uses <xref:System.Web.HttpRuntime>, it might be necessary to start up the `SystemWebAdapters` service, as shown in the following example:
:::code language="csharp" source="~/migration/inc/samples/unit-testing/Program.cs" id="snippet_UnitTestingFixture" :::
2023-10-04 02:23:46 +08:00
The tests must be executed in sequence, not in parallel. The preceding example illustrates how to achieve this by setting [XUnit's `DisableParallelization` option](https://xunit.net/docs/running-tests-in-parallel#parallelism-in-test-frameworks) to `true`. This setting disables parallel execution for a specific test collection, ensuring that the tests within that collection run one after the other, without concurrency.