For a new .NET test project, the current xUnit.net v3 getting-started path is to install the xUnit template, create a project with dotnet new xunit3, write a [Fact] or data-driven [Theory], then run the generated project with dotnet run. This tutorial follows that v3 path; it is not a drop-in setup guide for an existing xUnit.net v2 project.
What you need to know about xUnit.net versions
xUnit.net is a unit-testing framework for C#, F#, and Visual Basic. The current v3 documentation supports .NET 8 or later and .NET Framework 4.7.2 or later; .NET Framework support is officially for Windows only. Check the current compatibility and package guidance before pinning versions, because the versions shown in documentation examples can change.
The xUnit.net getting-started guide dated 2026-05-02 identifies its example snapshot as xUnit.net v3 4.0.0-pre.108 with .NET SDK 10.0.102. These are the versions used in that guide’s example, not a timeless recommendation to pin those exact versions.
| Choice | What changes | When to use it |
|---|---|---|
| xUnit.net v3 | The documented project can be a stand-alone executable, with newer minimum runtime requirements: .NET 8 or .NET Framework 4.7.2. | Use the v3 setup below for a new project when your target framework and runner path fit. |
| xUnit.net v2 | Existing v2 projects are library projects and rely on a test runner. Their package and execution setup differs from v3. | Keep using the v2 tutorial for an existing v2 solution; consult the migration guide before upgrading. |
Do not mix v2 package instructions into a v3 project. The official guides for v3 getting started, v2 getting started, and v3 migration describe the version-specific paths.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Create a v3 test project
The official v3 command-line quick start uses an xUnit template and a project configured for Microsoft Testing Platform. The templates are available for C#, F#, and VB.NET.
-
Install the template package:
dotnet new install xunit.v3.templates -
Create a project in the current directory:
dotnet new xunit3 -
Run the generated stand-alone test project:
dotnet runSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Run these commands in a directory where you want the test project. The template creates the project files and an example test; inspect the generated project file if you need to confirm which runner configuration it selected.
Choose the runner deliberately
The default project in the v3 quick start uses the xunit.v3.mtp-v2 setup for Microsoft Testing Platform. If you need the VSTest path—for example, to use the Visual Studio Test Explorer or Visual Studio Code Testing panel—the xUnit.net documentation calls for xunit.runner.visualstudio and Microsoft.NET.Test.Sdk. Use the package setup appropriate to the runner and follow its documented invocation rather than assuming dotnet run and dotnet test are interchangeable in every project.
Microsoft Learn’s separate tutorial creates a solution with source and test projects and runs tests with dotnet test. That is a useful workflow when you want the application and tests in distinct projects; it is not the same project layout as the quick-start stand-alone v3 executable.
Write a first test with [Fact]
A fact checks one expected outcome without a data set. xUnit.net describes facts as tests that are always true: they test invariant conditions. A useful test names the behavior and asserts its observable result, rather than merely checking that the test method ran.
Recommended Free Tools
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
using Xunit;
public class PriceCalculatorTests
{
[Fact]
public void ApplyDiscount_ReducesPriceByTenPercent()
{
var calculator = new PriceCalculator();
decimal result = calculator.ApplyDiscount(100m);
Assert.Equal(90m, result);
}
}
public class PriceCalculator
{
public decimal ApplyDiscount(decimal price)
{
return price * 0.90m;
}
}
This small example tests a specific contract: applying the discount to 100 returns 90. In a real codebase, keep production code and test code in the project structure your solution uses; the key is that the assertion expresses the expected behavior clearly.
Use test-first development when it helps
Microsoft Learn’s xUnit tutorial demonstrates a test-first loop with a prime-checking service: write a test for behavior that is not implemented yet, observe the failure, implement the behavior, then add cases. The initial failure is expected in this workflow. It gives you a concrete target and helps reveal whether the implementation meets the requirement.
Use [Theory] for several inputs
A theory runs the same test body against specified data. xUnit.net distinguishes the two this way: “Theories are tests which are only true for a particular set of data.” With [InlineData], each row supplies one input and expected result, and the runner reports each data row as an individual test.
using Xunit;
public class DiscountTests
{
[Theory]
[InlineData(100, 90)]
[InlineData(50, 45)]
[InlineData(0, 0)]
public void ApplyDiscount_ReturnsNinetyPercentOfPrice(
decimal price,
decimal expected)
{
var calculator = new PriceCalculator();
Assert.Equal(expected, calculator.ApplyDiscount(price));
}
}
Use a fact when the condition is a single invariant; use a theory when the same behavior should be checked for multiple meaningful inputs. Keep the method name focused on the behavior, and choose data that makes the expected contract apparent. When one row fails, the runner can identify the case that exposed the problem.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Run tests and interpret failures
Run the default generated v3 project
For the default Microsoft Testing Platform project created by the v3 template, run dotnet run from the project directory, as shown in the official v3 quick start. The command executes the stand-alone test program and reports test outcomes in the terminal.
Run a VSTest-configured project
For projects configured with the VSTest adapter and test SDK, use the VSTest workflow, commonly dotnet test for a solution or test project. Microsoft Learn’s xUnit tutorial uses this command. In Visual Studio, use Test Explorer; in Visual Studio Code, use the Testing panel when the VSTest adapter setup is present.
Read a failed assertion as a diagnosis
A failing test report identifies the test (and for a theory, the data case) and compares the expected and actual values. For example, if a test expects 90 but receives 100, the implementation may not apply the discount, or the test may be exercising a different rule than intended. Check the named test and input first, then decide whether the requirement, assertion, or production code needs correction. A failure is useful output, not merely a red status.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Common setup and test problems
-
The template command is unavailable: confirm that the template package installation completed with
dotnet new install xunit.v3.templates, then retrydotnet new xunit3.Recommended: Fix Windows Errors and Clear Junk Files in Minutes - Free Scan →Recommended: Crashes or Glitches? A Free Driver Scan Usually Finds the Culprit →Recommended: PC Feels Slow? A Free Scan Shows What's Dragging Windows Down →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
-
The project targets an unsupported framework: verify the target against the v3 minimums (.NET 8 or .NET Framework 4.7.2) and consult the current compatibility guidance. For .NET Framework, the official support stated by xUnit.net is Windows-only.
-
Your IDE does not discover tests: check which runner the project uses. The default v3 template path is Microsoft Testing Platform; VSTest discovery requires the documented
xunit.runner.visualstudioandMicrosoft.NET.Test.Sdksetup. -
dotnet testdoes not fit the project you created: check the project’s runner configuration and use the command documented for it. The v3 quick start’s default stand-alone project is run withdotnet run; the Microsoft Learn solution/test-project workflow usesdotnet test. -
A test fails unexpectedly: inspect the failing test name, theory input if applicable, and expected-versus-actual values. Confirm the assertion matches the intended behavior before changing implementation code.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
You are maintaining a v2 project: do not replace its packages or commands with the v3 template workflow without planning a migration. Start with the official v2 guide and migration documentation.
Or skip the browser setup
If you need a website screenshot as part of a test fixture or visual-check workflow, ScreenshotNeo is a screenshot API and MCP server for developers. One GET request returns a PNG, JPEG, WebP, or PDF; its options include custom headers, cookies, user agent, viewport, CSS, and JavaScript. For example, a test setup or helper can request a screenshot of a target page:
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Cookie banners, newsletter popups, and chat widgets are removed before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up free for ScreenshotNeo.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




