Revisiting Test Context Classes in C++

In an earlier post, I described how I like to use disposable objects when writing functional tests in C#, to reliably cleanup resources and to promote code reuse across tests. I’ve been writing more tests in C++ recently, so I thought I would revisit the concept of resource-context classes…

Practical Considerations for Using Disposable Resource-Context Classes for Functional Tests in C#

In my previous post, I described how I use disposable classes to handle complex initialization and cleanup for functional tests in C#. In this post, I’ll cover some practical considerations for using these contexts. Using Multiple Contexts Some tests require multiple resources. For example, a test that lists all…

Disposable Resource-Context Classes for Functional Tests in C#

Automated tests generally follow the Arrange, Act, Assert pattern. First, establish the preconditions of the test, then execute the functionality under test, and, finally, assert that the result meets the expectation. The Arrange portion of a unit test is usually trivial. Functional tests, however, can often have fairly involved preconditions…

Reflections on Enforcing Coding Style to Commit Code

I was recently part of a team implementing a new cloud service. One of the objectives of this team was to frequently release software to production. This might be a minor patch or the introduction of a significant new feature. After some careful investments in automated builds, deployments and tests,…

Writing Automated Tests for Custom Windows Performance Counters

As I mentioned in my previous post, I really like using Windows Performance Counters in automated tests to gain insights into applications. It is not difficult to expose custom Performance Counters from your own application to report various metrics. But what about testing these custom counters? Like any other component…

Tricks with Windows Performance Counters for Automated Tests

I really like Windows Performance Counters. I find them a powerful tool for understanding applications under development and for monitoring and troubleshooting applications in production environments. Windows Performance Counters are available for reporting absolute values (e.g., Memory\Available Bytes), counts (e.g., Network Adapter\Packets Received Discarded), rates (e.…

Tests That Involve Time Are Hard

I've written a lot of automated tests that involve time and time-series data. I've also maintained many similar tests written by others. Given that these tests involve time and sometimes subtle timing, they can often be less deterministic than tests that only involve static data. I've written tests that passed…

Avoid Handling Exceptions in Negative Tests

Unit tests that provide coverage for every exception a method can throw are invaluable. When writing these tests, the developer needs to carefully consider (or reconsider) the exceptions being thrown, along with how they will ultimately be handled by the caller. This exercise alone often results in improvements to the…

Inaugural Post

Welcome to my blog. My intentions are to write about software development, including the temperament and character of individuals, teams and organizations. I hope to post something new once or twice a month. I don't expect to become a prolific writer or become the next Joel on Software. Rather, my…