Shaun Abram
Technology and Leadership Blog
Blog post summary: We need to talk about testing
I liked this “We need to talk about testing” post from Dan North. It’s about what testing actually means and how programmers and testers can work together. A summary (or copy & paste of the parts that I found most interesting, with some comments) below…
The purpose of testing is to increase confidence for stakeholders through evidence.
Tags: quality, summary, tdd, Testing, unittesting
Unit Testing – the Hard Parts @ NYC Code Camp
Thanks to everyone who came to my “Unit Testing – the Hard Parts” presentation @ New York Code Camp. I really enjoyed it! Great crowd, lots of follow up questions. And cool Microsoft office space in Times Square. Thank you to all who attended. My slides are here: http://www.slideshare.net/shaunabram/unit-testing-the-hard-parts
Tags: codecamp, mocks, mytalks, nycc, stubs, tdd, testdoubles, testdrivendevelopment, Testing, unittesting
Test Doubles: mocks, dummies and stubs
Most classes have collaborators. When unit testing, you usually want to avoid using real implementations of those collaborators to avoid test brittleness and binding/coupling, and instead use Test Doubles: Mocks, Stubs and Doubles.
This article references two existing articles on the subject: Mocks Aren’t Stubs, by Martin Fowler and The Little Mocker, by “Uncle” Bob Martin. I recommend them both.
Tags: doubles, dummies, fakes, martinfowler, mockito, mocks, spies, tdd, testdoubles, Testing, unclebob, unittesting
Testing for expected exceptions in JUnit
Unit tests are used to verify that a piece of code operates as the developer expects it to. Sometimes, that means checking that the code throws expected exceptions too. JUnit is the standard for unit testing in Java and provides several mechanisms for verifying exceptions were thrown. This article explores the options and their relative merits.
(Note: There are other good options for testing for exceptions using AssertJ, rather than vanilla JUnit. See https://www.baeldung.com/assertj-exception-assertion)
(more…)
Tags: exceptions, JUnit, tdd, unittesting
Software Quality via Unit Testing
The following post is based on a talk I gave at Desert Code Camp 2013. See also the associated slide deck.
Software quality is critical to consistently and continually delivering new features to our users. This articles covers the importance of software quality and how to deliver it via unit testing, Test Driven Development and clean code in general.
Read more
Tags: cleancode, codecamp, dcc13, desertcodecamp, JUnit, martinfowler, mytalks, talks, tdd, Testing, unittesting
OSCON Day1: Test Driven Database Development
The first tutorial at OSCON was on Test Driven Database Development. The idea was to use pgTAP to write unit tests to check database correctness, including table structures, views and stored procedures. As a fan of Test Driven Development (TDD) for regular code, the concept of using it on the database tier makes a lot of sense.
Unfortunately I had a lot of problems getting the required software setup working, which included PostgreSQL, pgTAP, Test::Harness, make and perl. Ultimately I wasn’t able to get the examples running due to imcompatabilities between PostgreSQL and pgTAP on my Macbook Pro (OS X 10.5.8) and ended with this error:
dyld: Library not loaded: /usr/local/lib/libxml2.2.dylib
Referenced from: /Library/PostgreSQL/8.4/lib/postgresql/pgxs/src/makefiles/../../src/test/regress/pg_regress
Reason: Incompatible library version: pg_regress requires version 10.0.0 or later, but libxml2.2.dylib provides version 9.0.0
I considered trying to upgrade libxml, but there were suggestions that this could cause my machine to not boot! I even considered upgrading to OS X 10.6 (Snow Leopard), but decided that this was a little too close to shaving yaks.
I would really like to get more familiar with pgTAP at some point, but I will have to put on hold for now…
Update: I managed to get some input from David Wheeler, worked through the technical issues and got all the tests running. Thanks David! Despite the earlier setup problems, I came away with a very positive feeling about TDDD and pgTAP and can see it playing a part in any future database schema development I do.