Error handling: Checking for exceptions

When we talked about understanding what we’re actually testing in error handling, we talked about the ability to understand the behavior of our code-under-test . Just to recall, here are the three types of error implementation, and what we can… Continue Reading…

Unit Testing Error Handling and Exceptions

One of the things that unit tests are best for is checking error conditions. While we want wider coverage of full happy flows, error conditions are sometimes hard to simulate in a big system, and unit tests excel at minimal setup to… Continue Reading…

Gil Zilberfeld explains how Unit tests (and integration tests) not only check that the code works, but are also hold useful information when they fail.

Triangulation: The Other Role Of Unit Tests

“Why do we need unit tests?” Seems like a silly question. We want to check if something is working, right? Let’s dig deeper, though. At the time of writing, if we’re using test-first or TDD, we’re designing interfaces, apply usage… Continue Reading…

Gil Zilberefld explains how multiple asserts are usually a sign of scope creep in unit tests. They may also create situations that delay solving the problem when the unit test fails.

The Unit Test Scope Creep

In “Should I use multiple asserts” we described the problem when using them in a single unit test. In the example I gave, while checking the result of a single operation, it still made sense to get information on both… Continue Reading…

Gil Zilberfeld explains why we would want to split unit tests with multiple assertions into single unit tests with single asserts.

Should I Use Or Split Multiple Asserts?

I get this unit testing question often. It makes efficient sense to stuff all kinds of assertions after a single setup and invocation. While there’s no one answer, for me, it usually comes down to: Try to separate rather than join… Continue Reading…

Gil Zilberfeld explains why some unit tests are not important to write, and may even cost you later. We don't need to get to complete code coverage by writing every unit test possible

Should We Write That Test?

As we’ve seen already, we don’t have to write every unit test possible, since not every unit test is going to help us in the future, and may even cause us some problems. Here’s an actual example I encountered. I’ll… Continue Reading…

Gil Zilberfeld explains why not every unit test or integration tests are valuable. We need to ask what bug will the unit test find, to see if want to keep it.

What Bug Will It Find?

“Is this a good unit test?” Usually the question refers to a test that somebody has already written. But are these unit tests effective? Should we have written it in the first place? That’s right, we don’t need to test… Continue Reading…

Copyright Gil Zilberfeld, 2025