Skill Zuno · skillzunos.com · Fullstack Pro
xUnit interview questions
Prepare for xUnit interviews on Skill Zuno. This practice book covers xUnit interview questions across New, Easy, Medium, Hard, and Diff levels so you can work through real interview-style problems on skillzunos.com.
Open xUnit on Skill ZunoAlso see the xUnit tutorial.
xUnit.net is a free, open-source unit testing framework for .NET, written by the original author of NUnit and widely used in ASP.NET Core projects. It favours simple conventions: a new test class instance per test, constructors for setup and IDisposable for cleanup. Interviews cover facts and theories, assertions, fixtures for shared context, mocking with Moq or NSubstitute and integration testing with WebApplicationFactory.
Sample xUnit interview questions
What is the difference between [Fact] and [Theory]?
A Fact is a test that is always true with no inputs. A Theory runs once for each set of data supplied by attributes such as [InlineData].
Why doesn't xUnit have [SetUp] and [TearDown] attributes?
xUnit creates a new instance of the test class for every test, so the constructor does setup and Dispose does cleanup, which keeps tests isolated.
What is a class fixture?
A class implementing IClassFixture<T> receives one shared T instance for all tests in that class, useful for expensive setup such as a database connection.
How do you test async code in xUnit?
Make the test method async Task and await the call. Use Assert.ThrowsAsync for exceptions, and IAsyncLifetime for async setup and cleanup.
What does WebApplicationFactory do?
It boots your ASP.NET Core app in memory with a test server and gives you an HttpClient, so you can send real HTTP requests through the full pipeline in tests.
What you can practice
- xUnit interview questions for beginners and experienced developers
- Level-based practice: New, Easy, Medium, Hard, and Diff
- Fullstack Pro topics alongside xUnit on skillzunos.com