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 check: No error handling – Any exception is handled somewhere Read more…
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 make sure our code handles the problem correctly. We have Read more…
Legacy Code to Testable Code #11: MOAR Static Constructors
The other posts in the series: Where we last left off, we discussed how to dismantle the static constructor (or initializer) booby traps. And I promised you an example. I’ll do that in C#, but the operations apply to any language that uses these constructs. Before I do that I’ll Read more…
The Power of Testability Compels You (Not)
Once more I get into a training session on unit testing, and once more I hear “It feels wrong to change my code just for testability.” My immediate reaction was “because the design you have right now is so good, right?” (yes, I said it out loud). Let’s break it Read more…
Unit Test, System Test, Red Test, Green Test
We tend to categorize different types of tests according to what they cover. Unit tests cover small portions of code, usually a method or a class, while we mock the rest of their interaction. Integration tests cover several components in concert, and then mock the other boundaries. System tests and Read more…
Legacy Code to Testable Code #6: Add Overload
This post is part of the “Legacy Code to Testable Code” series. In the series we’ll talk about making refactoring steps before writing unit tests for legacy code, and how they make our life easier. Other posts include: In the last post, I’ve talked about Extract Class refactoring pattern, Read more…
Legacy Code to Testable Code #5: Extract Class
This post is part of the “Legacy Code to Testable Code” series. In the series we’ll talk about making refactoring steps before writing unit tests for legacy code, and how they make our life easier. Other posts include: A few years ago I got this from Erik Talboom: “A private Read more…
Legacy Code to Testable Code #4: More Accessors!
This post is part of the “Legacy Code to Testable Code” series. In the series we’ll talk about making refactoring steps before writing unit tests for legacy code, and how they make our life easier. It continues the last post on accessors. Other posts include: We talked about refactoring Read more…
Legacy Code to Testable Code #3: Adding Setter Accessors
This post is part of the “Legacy Code to Testable Code” series. In the series we’ll talk about making refactoring steps before writing unit tests for legacy code, and how they make our life easier. Other posts include: Adding accessors to private state data is an admission that either our Read more…