For a new xUnit.net v3 project, install the .NET SDK, create the xunit3 template, and run dotnet run from the generated project directory. If you already have an xUnit.net v2 project, keep its matching setup: the documented v2 route uses dotnet new xunit and dotnet test. The commands differ because the project template and test runner configuration differ.
Run your first test with the xUnit.net v3 template
This route follows xUnit.net’s v3 getting-started guide. Its examples use xUnit.net v3 4.0.0-pre.108, .NET SDK 10.0.102, and .NET 8; those are example versions, not requirements. Template output and commands can change with SDK and template releases.
1. Check that the .NET SDK is available
Install the .NET SDK for your operating system, open a fresh terminal, and run:
dotnet --version
The command should print an SDK version. The version shown in the xUnit guide is 10.0.102; use an SDK supported by your project rather than treating that example as mandatory. If the shell says dotnet is not recognized or cannot be found, install the SDK and reopen the terminal so its PATH is refreshed.
#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.
2. Install the v3 templates and create a project
Run these commands in order:
dotnet new install xunit.v3.templates
mkdir MyFirstUnitTests
cd MyFirstUnitTests
dotnet new xunit3
The template package provides xunit3 and xunit3-extension templates, with C#, F#, and VB.NET support. Use xunit3 for a normal test project. Project creation restores the generated project in the guide’s example; if restore fails, resolve the SDK or package-source error reported in the terminal before running tests.
3. Inspect the generated test
Open UnitTest1.cs. The C# example generated by the template contains a test marked with [Fact] and a trivial Assert.True(true) assertion. The example project file targets net8.0, uses OutputType Exe, enables TestingPlatformDotnetTestSupport, and includes xunit.runner.json. These are template-example settings and may vary with template options and SDK version.
Rank #2
- 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.
4. Run the project
From the test-project directory, run:
dotnet run
A successful run should show the test being discovered and executed, with one test and no errors or failures in the guide’s simple example. Exact wording and formatting depend on the runner version. If the project reports that no tests were found, check that you are in the generated project directory and that the template’s runner configuration has not been removed or changed.
5. Replace the placeholder with a useful assertion
A test is useful when it checks behavior your program needs to preserve. For example, if your project has an Add method, an assertion can check a known result:
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.
Assert.Equal(4, Add(2, 2));
Run the test again after changing it. The xUnit guide also demonstrates an intentionally incorrect expected value: a failing test reports expected and actual values and a source location. That is a diagnostic example; change the expected value to the behavior your code should produce rather than leaving a deliberately failing test in your suite.
Choose between a fact and a theory
Use [Fact] for one invariant check
A fact checks a condition that should hold without varying its input. xUnit.net’s v3 guide puts it this way: “Facts are tests which are always true. They test invariant conditions.” The generated placeholder is a fact, but a meaningful fact should assert an outcome, such as the result of a calculation or a state change.
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
Use [Theory] when the same behavior needs several inputs
A theory runs a test against specified data, commonly supplied with attributes such as [InlineData]. For example, one addition rule can be checked with multiple input pairs. The v2 guide’s example runs once per input and identifies a failing input in the output. Use a fact for a single invariant and a theory when varied inputs exercise the same rule.
If your project uses xUnit.net v2
Do not apply the v3 template and runner instructions to an existing v2 project without checking its configuration. The documented v2 guide, dated July 4, 2025, uses dotnet new xunit and dotnet test. Its VSTest setup references xunit, xunit.runner.visualstudio, and Microsoft.NET.Test.Sdk.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
- 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.
dotnet new xunit
dotnet test
That guide uses xUnit.net v2 2.9.3, .NET SDK 9.0.301, and .NET 8 as examples, not universal requirements. It describes v2 as being in maintenance mode, with critical bug fixes continuing and new feature work in v3. For an existing project, inspect its project file and follow the instructions for its current version and runner; migration is a separate decision, not a prerequisite for running its tests.
| Setup | Template command | Runner path shown in the guide | Run command |
|---|---|---|---|
| xUnit.net v3, new project | dotnet new xunit3 |
Microsoft Testing Platform by default in the getting-started example; VSTest is also available with its runner packages | dotnet run for the documented default example |
| xUnit.net v2, documented VSTest path | dotnet new xunit |
xunit.runner.visualstudio and Microsoft.NET.Test.Sdk, alongside xunit |
dotnet test |
The v3 template overview also describes support for dotnet test and Visual Studio Test Explorer. The correct command depends on the generated template and selected runner configuration; do not infer the runner only from the xUnit version number.
Use an editor if you prefer
The terminal is enough for the first run. The official xUnit instructions also describe Visual Studio Test Explorer when the VSTest-related references enable discovery, and VS Code with Microsoft’s C# Dev Kit and the relevant runner packages. An editor is optional; it is not required to create or run the test project.
Troubleshoot a first run
dotnetis unavailable: the SDK is missing or the terminal has not picked up its PATH. Install the SDK for your OS and open a new terminal, then retrydotnet --version.- Template name is not recognized: install
xunit.v3.templatesbefore runningdotnet new xunit3. For the documented v2 template, usedotnet new xunitinstead. - Restore fails: project creation or execution cannot retrieve required packages. Read the restore error, check SDK and package-source availability, and rerun restore before testing.
- No tests are discovered: confirm the current directory contains the intended project and that its runner configuration and required package references match its template and runner choice.
dotnet runordotnet testseems wrong for the project: check the project version and runner setup. The v3 getting-started example usesdotnet run; the documented v2 VSTest example usesdotnet test, and v3 also supports VSTest configurations.- A test fails: compare the expected and actual values and inspect the reported source location. If you used the guide’s deliberately wrong expectation, correct it; otherwise decide whether the assertion or the implementation conflicts with the intended behavior.
Or skip the browser setup
ScreenshotNeo is a website screenshot API, not a test runner, so it does not replace these xUnit commands. If you separately need a website capture in a developer workflow, its API can return a screenshot; see the ScreenshotNeo documentation.
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
ScreenshotNeo removes cookie banners, popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. It also provides an MCP server for AI agents to take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo’s free plan.
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.

