Boundary and classification rules
8 exercisesChoose values on, just below, and just above a rule. These exercises build the habit that catches off-by-one defects and missing branches.
Free C# test-writing practice in the browser
The implementation is already correct. You write the suite, then mutation-based grading checks whether it catches real mistakes across 24 focused C# exercises and 134 planted bugs.
All exercises are available on every plan. No SDK or test-project setup.
Green is the start, not the proof
A passing test suite can still assert the wrong things, miss every boundary, or execute a branch without checking its outcome. Line coverage cannot tell those cases apart.
Each exercise supplies one correct subject and five or six deliberately faulty versions. Your suite must stay green on the first and turn enough of the others red. The feedback names every caught and surviving mutant without revealing its source.
New to the craft? Read the unit testing best-practices guide, then use mutation grading to turn the advice into a repeatable judgment.
Your submission
The implementation is supplied. Your inputs and assertions are the solution.
Correct implementation
Every test must pass
Five planted faulty versions
CAUGHT
boundary moved
CAUGHT
branch removed
CAUGHT
operator swapped
CAUGHT
case ignored
SURVIVED
edge survives
4 of 5 caught → grade passed
Four unit-testing skill families
The catalog moves from isolated decision boundaries to behavior that needs sequences, time, sorting, and state. Each family trains a different way shallow tests let defects survive.
Choose values on, just below, and just above a rule. These exercises build the habit that catches off-by-one defects and missing branches.
Partition strings into meaningful input classes, then target ordering, normalization, invalid data, and representation edge cases.
Turn prose into an executable contract across thresholds, sequencing rules, rounding, error cases, and combinations of behavior.
Design sequences where earlier calls change later outcomes. Timing, eviction order, sorting, and calendar rollovers make shallow tests survive.
24 free C# unit testing exercises
Start with a single formula or classification boundary, then work toward caches, calendars, rate limits, and business rules. Every card opens the actual exercise.
8 focused reps
Choose inputs that expose each mistake in the conversion formula.
Write this test suite →Cover values below, above, inside, and exactly on both boundaries.
Write this test suite →Isolate plain, Fizz, Buzz, and combined FizzBuzz branches.
Write this test suite →Separate divisible-by-four, century, and four-hundred-year rules.
Write this test suite →Test both sides of every cutoff to catch off-by-one defects.
Write this test suite →Prove each argument can win, including ties and negative values.
Write this test suite →Cover case, punctuation, empty text, and asymmetric strings.
Write this test suite →Cover each shape, impossible sides, and degenerate boundaries.
Write this test suite →7 focused reps
Pin bracket type, nesting order, and every unbalanced case.
Write this test suite →Cover wraparound, letter case, punctuation, and normalized shifts.
Write this test suite →Distinguish every vowel, case, empty input, and tempting non-vowels.
Write this test suite →Pin digit doubling, reduction, checksum validity, and rejected inputs.
Write this test suite →Exercise each symbol and all six subtractive combinations.
Write this test suite →Cover run boundaries, multi-digit counts, singletons, and empty input.
Write this test suite →Prove version segments compare numerically rather than lexically.
Write this test suite →5 focused reps
Exercise open frames, spares, strikes, and the final-frame bonus rolls.
Write this test suite →Prove each band is taxed marginally and every threshold is correct.
Write this test suite →Isolate each policy rule so dropping any one rule is detected.
Write this test suite →Pin operand order, chained operations, and invalid expressions.
Write this test suite →Prove every cent is allocated when a total divides unevenly.
Write this test suite →4 focused reps
Pin overlap, touching intervals, containment, and input sorting.
Write this test suite →Build call sequences that prove which entry is truly least recently used.
Write this test suite →Exercise ordinary days, month ends, year ends, and leap February.
Write this test suite →Use timed call sequences to prove the window slides and the limit holds.
Write this test suite →The mutation-testing practice loop
01
Inspect a correct C# implementation and its contract. Your task is not to rewrite the subject; it is to decide which examples would expose a wrong version.
02
Add public test methods with focused inputs and assertions. Every test must agree with the correct implementation before it can judge anything else.
03
Submit the suite against several hidden faulty implementations. The result names each mutant as caught or survived, so the missing edge case has somewhere to hide.
Katabench uses authored faulty implementations rather than mutating your code at runtime, but the principle is the same as mutation testing in .NET: a test proves its value when a meaningful defect makes it fail.
C# unit testing exercise FAQ
They are small C# programs where the implementation is already correct and your solution is the test suite. You choose inputs, write assertions, and cover boundaries, invalid data, state changes, and combinations of behavior that a shallow suite would miss.
Katabench runs your suite against the correct implementation first, where every test must pass. It then runs the same suite against several planted faulty versions, called mutants. You pass only after your tests fail against enough of those bugs, proving the assertions can detect regressions rather than merely execute code.
Yes. The complete Test Writing track is currently available on all plans. Daily graded-submission limits still depend on your plan, but none of these exercises is locked behind a specialized-track entitlement.
Katabench uses a small built-in assertion API and treats each public parameterless method as a test, so the exercise stays focused on test design instead of package setup. The boundary analysis, assertions, exception checks, and naming habits transfer directly to xUnit, NUnit, and MSTest.
No. The editor, compiler, correct subject, planted faulty versions, and result panel run from the browser in disposable server-side sandboxes.
In an ordinary challenge you implement a function and supplied tests judge your code. Here the function is supplied and correct: you write the tests, then faulty implementations judge how strong those tests really are.
Want a different kind of practice? Browse all C# coding challenges across algorithms, data access, refactoring, architecture, security, and test writing.
Start with FizzBuzz: four behavioral branches, five planted faulty versions, and immediate feedback on which bugs your tests caught.
Test FizzBuzz freeA short note when fresh kata land, plus the C# and performance tricks behind the grading. No spam, unsubscribe anytime.