Dotnet Testing Advanced Xunit Upgrade Guide logo

Dotnet Testing Advanced Xunit Upgrade Guide

Community
kevintsengtw
dotnet-testing-advanced-xunit-upgrade-guide

xUnit 2.9.x 到 3.x 升級完整指南。當需要將 xUnit v2 升級至 v3 或了解 xUnit v3 新功能與破壞性變更時使用。涵蓋套件更新、async void 修正、IAsyncLifetime 調整。包含新功能介紹: Assert.Skip、Explicit Tests、Matrix Theory、Assembly Fixtures。 Keywords: xunit upgrade, xunit v3, xunit 3.x, xunit migration, xunit 升級, xunit.v3, OutputType Exe, IAsyncLifetime v3, Assert.Skip, SkipUnless, SkipWhen, Explicit attribute, MatrixTheoryData, AssemblyFixture, 破壞性變更

Overview

Publisherkevintsengtw
Repositorydotnet-testing-agent-skills
Skill namedotnet-testing-advanced-xunit-upgrade-guide
Stars
30
Forks
4
Bundled files
8
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 8 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by kevintsengtw on GitHub. Read the source before you install it.

Installation

Install the Dotnet Testing Advanced Xunit Upgrade Guide AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/kevintsengtw/dotnet-testing-agent-skills/tree/main/skills/dotnet-testing-advanced-xunit-upgrade-guide
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/kevintsengtw/dotnet-testing-agent-skills.git /tmp/dotnet-testing-agent-skills
mkdir -p .claude/skills
cp -r /tmp/dotnet-testing-agent-skills/skills/dotnet-testing-advanced-xunit-upgrade-guide .claude/skills/dotnet-testing-advanced-xunit-upgrade-guide
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Dotnet Testing Advanced Xunit Upgrade Guide in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Dotnet Testing Advanced Xunit Upgrade Guide on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Dotnet Testing Advanced Xunit Upgrade Guide is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

xUnit 升級指南:從 2.9.x 到 3.x

核心概念

套件命名變革

xUnit v3 採用全新的套件命名策略:

v1~v2 套件名稱v3 套件名稱說明
xunitxunit.v3主要測試框架
xunit.assertxunit.v3.assert斷言函式庫
xunit.corexunit.v3.core核心元件
xunit.abstractions(移除)不再需要
xunit.runner.visualstudioxunit.runner.visualstudio (3.x.y)測試執行器

重要:使用 xunit.v3 套件名稱,不是 xunit。

最低運行時需求

  • .NET Framework 4.7.2+ 或 .NET 8.0+ (推薦)
  • 不支援:.NET Core 3.1、.NET 5/6/7

破壞性變更

涵蓋 OutputType 改為 Exe、async void 不再支援、IAsyncLifetime 繼承 IAsyncDisposable、SkippableFact 移除、僅支援 SDK-style 專案、自訂 DataAttribute 簽名變更等六項破壞性變更,每項皆附修正前後的程式碼對照。

完整破壞性變更清單與程式碼範例請參考 references/breaking-changes.md


升級步驟

五步驟 SOP:建立升級分支 → 更新專案檔案(套件、OutputType)→ 修正 async void → 更新 using → 編譯與測試。另含 .NET 10 SDK MTP 模式遷移指南(global.json 設定、CLI 用法變更、VSTest 遷移步驟)。

完整升級步驟與 .NET 10 MTP 模式指南請參考 references/upgrade-steps.md


xUnit 3.x 新功能

涵蓋 Assert.Skip / SkipUnless / SkipWhen 動態跳過、Explicit Tests、[Test] 屬性、MatrixTheoryData 矩陣測試、Assembly Fixtures、Test Pipeline Startup、多格式測試報告等新功能,每項皆附完整程式碼範例。

完整新功能範例請參考 references/new-features.md

Testcontainers.XunitV3 整合套件

Testcontainers 官方推出 Testcontainers.XunitV3(4.9.0),專為 xUnit v3 設計的整合套件,自動管理容器的建立與銷毀,取代手動實作 IAsyncLifetime 的方式。

xml
<PackageReference Include="Testcontainers.XunitV3" Version="4.9.0" />

若專案同時使用 Testcontainers 與 xUnit v3,建議採用此套件簡化容器生命週期管理。


xunit.runner.json 設定

json
{
  "$schema": "https://xunit.net/schema/v3/xunit.runner.schema.json",
  "parallelAlgorithm": "conservative",
  "maxParallelThreads": 4,
  "diagnosticMessages": true,
  "internalDiagnosticMessages": false,
  "methodDisplay": "classAndMethod",
  "preEnumerateTheories": true,
  "stopOnFail": false
}

常見問題與解決方案

問題 1:找不到 xunit.abstractions

移除 using Xunit.Abstractions;,相關類型已移到 Xunit 命名空間。

問題 2:IDE 無法發現測試

確認 IDE 版本:Visual Studio 2022 17.8+、Rider 2023.3+、VS Code 最新版。如仍有問題,可暫時停用 MTP:

xml
<PropertyGroup>
  <EnableMicrosoftTestingPlatform>false</EnableMicrosoftTestingPlatform>
</PropertyGroup>

.NET 10 SDK 注意:若使用 MTP 模式,停用 MTP 會導致 dotnet test 錯誤。應改為移除 global.json 中的 test 區段。


升級檢查清單

升級前

  • 確認目標框架版本 (.NET 8+ 或 .NET Framework 4.7.2+)
  • 檢查專案檔案格式 (SDK-style)
  • 識別所有 async void 測試方法
  • 檢查 IAsyncLifetime 實作
  • 評估相依套件相容性
  • 建立備份分支

升級過程

  • 更新套件參考 (使用 xunit.v3)
  • 移除 xunit.abstractions 參考
  • 修改 OutputType 為 Exe
  • 修正所有 async void 測試方法
  • 更新 using 陳述式
  • 重構自訂屬性 (如有)
  • 驗證編譯成功
  • 執行所有測試

升級後驗證

  • 功能完整性測試
  • 效能基準比較
  • CI/CD Pipeline 驗證
  • 文檔更新
  • 團隊培訓
  • (.NET 10+)設定 global.json 啟用 MTP 模式並驗證 dotnet test 正常運作

IDE 與工具支援

IDE最低版本
Visual Studio2022 17.8+
VS Code最新版
Rider2023.3+

xUnit 3.x 預設啟用 Microsoft Testing Platform(MTP),搭配 .NET 10 SDK 可使用原生 MTP 模式。

.NET 10 MTP 模式詳細設定請參考 references/upgrade-steps.md


輸出格式

  • 產生升級後的測試專案 .csproj 設定(xunit.v3 套件、OutputType Exe)
  • 包含 async void 修正為 async Task 的測試程式碼
  • 包含 IAsyncLifetime 調整與 SkippableFact 替換範例
  • 產生 xunit.runner.json 設定檔

參考資源

範例檔案

原始文章

本技能內容提煉自「老派軟體工程師的測試修練 - 30 天挑戰」系列文章:

官方文件

相關技能

  • dotnet-testing-xunit-project-setup - xUnit 專案設定基礎
  • dotnet-testing-advanced-tunit-fundamentals - TUnit 替代框架
  • dotnet-testing-advanced-testcontainers-database - Testcontainers 資料庫整合測試(搭配 XunitV3 套件)

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Dotnet Testing Advanced Xunit Upgrade Guide AI skill do?

xUnit 2.9.x 到 3.x 升級完整指南。當需要將 xUnit v2 升級至 v3 或了解 xUnit v3 新功能與破壞性變更時使用。涵蓋套件更新、async void 修正、IAsyncLifetime 調整。包含新功能介紹: Assert.Skip、Explicit Tests、Matrix Theory、Assembly Fixtures。 Keywords: xunit upgrade, xunit v3, xunit 3.x, xunit migration, xunit 升級, xunit.v3, OutputType Exe, IAsyncLifetime v3, Assert.Skip, SkipUnless, SkipWhen, Explicit attribute, MatrixTheoryData, AssemblyFixture, 破壞性變更

Why use Dotnet Testing Advanced Xunit Upgrade Guide on TypingMind?

Because you install it once and use it with any model. Dotnet Testing Advanced Xunit Upgrade Guide is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Dotnet Testing Advanced Xunit Upgrade Guide in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/kevintsengtw/dotnet-testing-agent-skills/tree/main/skills/dotnet-testing-advanced-xunit-upgrade-guide. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Dotnet Testing Advanced Xunit Upgrade Guide?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Dotnet Testing Advanced Xunit Upgrade Guide?

As many as you like. As long as a model supports skills, you can use Dotnet Testing Advanced Xunit Upgrade Guide with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Dotnet Testing Advanced Xunit Upgrade Guide AI skill free?

Yes. It is published on GitHub by kevintsengtw under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇