What Are Micro-Tests?

Micro-tests make incremental development faster
Standard

There are unit tests, integration tests, API tests, end-to-end tests and other “test” animals. (No animal was tested for this post).

These types of tests are based on what they test. Unit tests test a code unit – a method, a class, a small set of classes. An API test checks our API behaves properly.

Micro-tests can be understood the same way: They test a very small portion of code (sort of a unit test). However, that’s not really what they are about.

Speed

They improve our speed of producing working code.

Micro-tests are small tests that test small code. But if you write them incrementally, you make a large piece of code faster. Which also works. You just don’t waste time on writing extra code that gets in your way of adding more code later. You don’t debug.

Think about it: Continuous work of adding code that works.

TDD focuses on adding just enough code – enough to work, and enough for us to focus on. We then move to the next bit. The smaller the bit, we move faster. We focus on the current small problem, solve it and move on to the next one.

We don’t debug, because that’s a big waste of our time. If we don’t understand what’s going on, we’re not in micro-land anymore. If we get stuck, we can (and should) revert. We haven’t written too much code since we were green anyway.

The smaller you cut your “feature”, with micro-tests, you’ll implement “all the features” – faster.

2 thoughts on “What Are Micro-Tests?

    • Gil Zilberfeld

      Yes, it’s a bit confusing, because we’ve got a lot of boxes and labels. But it depends on how you think about unit tests. “unit” is about WHAT you are testing – a method, or a class. A small piece of code. So in that way “micro” may equal unit.
      But… if you’re thinking from the perspective of programming flow, when every test moves you closer to the goal, and you move in small incremental steps, that’s where the micro test definition really shines. Because at the end of the day, you don’t think “man, that class is really well tested”. You think, “man, that feature works.” And the best way to get there is by small incremental tests.

Leave a Reply

Your email address will not be published. Required fields are marked *