HomeChallengesRepsProblemsLeaderboardTake a challenge

Your first xUnit test

A [Fact], a name that says what it checks, and an assertion that can fail.

Beginner12 min on the clock5 graded checks · 100 pointsTesting an ASP.NET Core API

AssumesYour first real testThe same ideas in a second language. Neither surface says whether it supersedes the other, complements it, or repeats it.

Graded by reading your code against the checklist below.

What you build

  • Write a [Fact] that checks the no-discount case
  • Name it so a failure in CI tells you what broke without opening the file
  • Assert on the returned value with Assert.Equal
  • Add a second and third case — a discount, and an empty order
  • Keep branching and loops out of the test body

Done means

Three named [Fact] tests, each asserting one thing, with no logic in the body.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. The tests are registered with [Fact]+20How a test is put together
  2. It asserts on the value that came back+20How a test is put together
  3. The name says what behaviour is being checked+20How a test is put together
  4. More than one case is covered+20How a test is put together
  5. No branching or loops in the test body+20How a test is put together

What it teaches

The rest of Testing an ASP.NET Core API