Delayed assert / multiple failures per test

A test stops execution once it hits a failing assert statement.
That’s kinda the point of an assert statement, though, so that’s not surprising.

However, sometimes it’s useful to continue with the test even with a failing assert.

I’m going to present one method for getting around this restriction, to test multiple things, allow multiple failures per test, and continue execution after a failure.

I’m not really going to describe the code in detail, but I will give the full source so that you can take it and run with it.

[Read more…]

Why Most Unit Testing is Waste

I don’t rememember how I ran across this article by James O Coplien. However, I was immediately impressed with the thought and experience that went into this paper.
Regardless of your viewpoints towards unit tests vs. other types of automated tests, this article is important to read.
If your first reaction to the title is anger, please take a deep breath, try to keep an open mind, and actually READ what Cope has to say.
I am going to reserve my own reactions to this to a future post, as I don’t want to color your views before you read it.
I am posting the entire article with no changes other than formatting.

[Read more…]

Software API/CLI interface adapters

While writing software, we are faced with lots and lots of interfaces.
The public interface for some tool or module or package or whatever is usually referred to as the API, the CLI, or simply the user interface.
In this post, when considering an interface, I am specifically referring to APIs and CLIs.

Sometimes, we find a software component that does exactly what we want, but the interface is not what we want.
That’s where software interface adapters come to the rescue.
Adapters are helpful in many stages of the design and development of just about anything.

Software interface adapters are perfect for functional testing.
On this site, I use a flavor of TDD that focuses on functional testing.
I’ve usually got a couple of goals:

  1. I want to test the public interface: either API, CLI, or both.
  2. I want the tests tat make up my regression test suite to be as easy to write as possible, so that it’s simple to add new tests as needed.

Often, these goals are at odds. The API/CLI may just not be convenient for easy testing.
That’s an ideal place to develop an interface adapter.

In this post, I’ll describe how interface adapters can be easily specified and implemented in python.
As a working example, I’ll describe the interface adapter that I need for testing

Read more about defining, implementing, and using interface adapters