← All tutorials

Skill Zuno · skillzunos.com · Fullstack Pro

xUnit tutorial

Learn xUnit on Skill Zuno. This xUnit tutorial covers New, Easy, Medium, Hard, and Diff levels so you can study practical xUnit problems on skillzunos.com.

Open xUnit on Skill Zuno

Also see the xUnit interview questions.

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.

xUnit topics covered

  • Facts and theories — [Fact] for single tests and [Theory] with InlineData, MemberData and ClassData.
  • Setup and cleanup — Using the constructor and IDisposable or IAsyncLifetime instead of setup attributes.
  • Sharing context — Class fixtures and collection fixtures for expensive shared resources.
  • Assertions — Assert.Equal, Assert.Throws and FluentAssertions or Shouldly for readable checks.
  • Mocking dependencies — Creating test doubles with Moq or NSubstitute.
  • Integration tests in ASP.NET Core — WebApplicationFactory, test servers and replacing services in tests.

What you can learn

  • xUnit tutorial for beginners and experienced developers
  • Level-based practice: New, Easy, Medium, Hard, and Diff
  • Fullstack Pro topics alongside xUnit on skillzunos.com

More Fullstack Pro tutorials

All tutorials