In the “How do I test an abstract base class if I can’t instantiate it?” post, you found out that you can actually test an abstract base class even though you can’t instantiate one.
The “all you need to do is” end of the post, however,
…
In the “How do I test an abstract base class if I can’t instantiate it?” post, you found out that you can actually test an abstract base class even though you can’t instantiate one.
The “all you need to do is” end of the post, however,
…
It is early afternoon. You just started your job at Glamorous Inc. Your buddy this morning talked about unit tests. How they want all code to have unit tests but also have code that was written before they started doing that. And they want you to start by getting some of that code under test.
…
The code you work on has this wonderful simple method. All it does is use a couple of other classes, passing through the parameters it received and setting some properties.
As it is such a simple function nobody bothered to write any tests for it. After all, “It only passes through to another class.”
…
It’s late in the afternoon. Almost time to go home. Just one issue to finish. A simple class that needs a couple of simple tests. Should be a breeze.
Five minutes later you are ready to bang your head against your desk. The error messages keep flying. And you can’t see why.
…
You have a set of classes to write. Classes that have details specific to each, but that also have a lot in common.
You don’t like to repeat yourself and like your code DRY.
So you have created a base class to contain all the common code.
…
Every so often this comes up: I have an interface. It has methods. I should unit test everything. So I should test this interface. But how? It doesn’t have an implementation…?!
Right…
Well…
Hmm…
No. Of course you don’t test the interface.
…
Well, yes. And no.
You shouldn’t be using literal values anyway. You should be using constants. And when you use constants everywhere, there is absolutely no point in testing whether a constant actually has the literal value assigned to it. No sense in testing the compiler. After all,
…