Practical Testing: 3 - Test 2, Enter The Mocks

I’m writing some blog entries that show how to write tests for non trivial pieces of code. This is part 3. Last time we wrote the first test. It doesn’t test much, but it proves we can test. Now we’ll write a real test for real functionality and along the way we’ll start to deal with some of the issues that come up when you’re trying to test multi-threaded code.

Monday Mornings

Updated 1st February 2024 to fix broken links Tell me about it. This morning I was shaving and thinking how I was actually early enough to be able to walk to Bank Tube station rather than jumping on the tube at Old Street. It looked like a nice morning and I had lots of plans for the code I was going to write today. It’s a busy week, and I had spent an hour or so late on Sunday making sure I was in a position to hit the ground running.

Practical Testing: 2 - The first test

I’m writing some blog entries that show how to write tests for non trivial pieces of code. This is part 2. In part 1 I introduced the code that we’re going to write a test for. Now we’ll move towards the all important first test. The first test is, in my opinion, vitally important; the first test proves that you can build a test harness that can create the object. This sounds easy, but try picking a class from your current project at random and writing a test that constructs an instance of that class.

Practical Testing: 1 - Introduction

I’m writing some blog entries that show how to write tests for non trivial pieces of code. This is part 1. The code that we’re going to test is CCallbackTimer. This is a class that lives in our Win32Tools library. It’s used by users of our SocketTools library. The class provides a very light-weight timer manager that gets around the various issues we had with using standard Win32 timers. The timer is designed to be used in vast quantities.

Practical Testing

One of the common complaints about TDD and unit testing that I see is that the examples used aren’t real. People often say that the examples used are toys and that writing such tests adds little or no value. To be honest, I often find myself agreeing with them. Last updated 25th April 2023 41 - GoogleTest - Moving to GoogleTest. One of the problems of adding unit tests to an existing code-base or driving a new project with TDD is deciding exactly where to spend your testing efforts.

Easy performance improvement for the socket server code

I was discussing the performance of The Server Framework with someone the other day and realised that there was a reasonably easy way to speed up some types of servers. I coded a first cut of the solution last night and, so far, it shows a small, but noticeable performance gain for no changes to functionality or code outside of the framework. The IOCP server framework was always designed for ease of use over performance.

Skate weekend

We managed to get in two skate sessions this weekend, which was nice. The weather was lovely and on Saturday we spent some time at Kensington Gardens. This was our third skate this year and we finally started to feel we’d got our legs back. On Sunday we were in Ilford, visiting my family, and just happened to have the skate gear in the car… We skated in Valentines Park for an hour or so; it was good.

The perils of premature 're-use'

Back in January I was writing a TCP/IP server for a client that acted as a connection gateway. Just as this project was coming to an end we started on another project which, at first, seemed quite similar; it was a TCP/IP server that provided gateway services. Just as we were starting out with this new project I made a fairly stupid decision and, well, four months later I’ve almost finished cleaning things up…

More than 20 years on and still as much to say

I’m currently re-reading The Mythical Man Month 20th Aniversay Edition and I’ve just finished watching Apocolypse Now Redux. Both seem to have as much to say now about their respective subjects as they did in the day. Brooks’ treatment of the “Joys” and “Woes” of The Craft as poignant as Coppola’s tale of the lies and horror of war.

Blog's a year old

Been a busy week, I meant to post this on The Day. I’ve been writing this stuff for just over a year now. I didn’t really know what to expect when I started, I just wanted a place to ramble on about this and that. During the year I’ve learned a few things about blogging…. I actually do do this for me more than for anyone else. I’ve found that I understand things more when I’ve written about them.