---
title: "What is unit testing and why does it matter?"  
description: "What is unit testing and why does it matter?"  
author: "Aashish Khadka"  
published: 2026-11-19  
updated: 2026-11-19  
canonical: https://www.mindstick.com/forum/163089/what-is-unit-testing-and-why-does-it-matter  
category: "software engineering"  
tags: ["unit testing", "xUnit", "test-driven development", "Software Quality", ".net"]  
reading_time: 1 minute  

---

# What is unit testing and why does it matter?

My manager wants unit tests for everything, but it feels like extra work. What is the benefit?

## Replies

### Reply by Guzel Mukhametova

A unit test runs one small piece of logic (a method or class) in isolation and checks that it gives the expected result. Tests run in milliseconds, automatically.

Benefits:

- **Catch bugs early**, when they are cheap to fix.
- **Safe refactoring**: if the tests still pass after you reorganise code, you probably did not break anything.
- **Living documentation**: tests show how the code is supposed to behave.
- **Faster development** over time, because you spend less time on manual re-testing and debugging.

A simple xUnit example:

```
[Fact]
public void Discount_For_Vip_Is_Ten_Percent()
{
    var price = new PriceCalculator().Apply(1000m, isVip: true);
    Assert.Equal(900m, price);
}
```

Tips: test behaviour, not implementation details; cover edge cases (zero, empty, null, limits); keep tests independent and readable (arrange, act, assert); mock only external things such as databases or APIs.

You do not need 100% coverage. Focus on important logic and bugs that have happened before.


---

Original Source: https://www.mindstick.com/forum/163089/what-is-unit-testing-and-why-does-it-matter

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
