Skip to main content

Posts

Showing posts from September, 2019

What Unit Testing Is

With that out of the way, let’s consider what actually does qualify.  Unit tests isolate and exercise specific  units  of your code.  Okay.  I’ll concede that I just punted by defining a term with a word in the term.  But the creators of the term left the designation deliberately vague, presumably to cross language boundaries. In C#, you can think of a unit as a method.  You thus write a unit test by writing something that tests a method.  Oh, and it tests something specific about that method  in isolation .  Don’t create something called TestAllTheThings and then proceed to call every method in a namespace. That’s really it — all there is to it.  You’ll notice that I haven’t mentioned a few things that might pop into your head, such as test-driven development (TDD),  unit test frameworks , test runners, mocks, or other unit testing tools.  Let’s not get ahead of ourselves.  Forget TDD and mocks for another time,...