Archive of Unit Testing
Unit Testing Servlets: A simple test for a complex servlet
Testing Java servlets reliably can often be difficult. Generally the main business logic is contained in a different class which can be tested in isolation, but in some cases it is necessary to have some logic in the servlet itself. It’s also nice to have a quick sanity check that the servlet…
Read MoreTaking C unit testing to the next level
In terms of formalised unit testing, we were fairly late to start generating repeatable test cases for our C products. Sure we wrote code to test our new features but they were just thrown away once the code was working. Even so, over the past 6 years or so, as…
Read MoreThe beauty of small tests
When tests are small, a test failure means just one thing – somewhere in these ten lines of code which are being tested, there is an error. Ok, sometimes this can mean that there is an error in the test script, or a there is a failure, or change of…
Read MoreAgile – Tests = Fragile
The nature of agile projects, with lots of small releases mean that there are a lot of test runs to execute if you want to have any confidence in the code and the product. Ignoring this testing just generates projects which will fail – not may fail – will fail,…
Read MoreTesting APIs for Backwards Compatibility
A couple of weeks ago, I wrote about Agile Framework Development and the various techniques that we have used here at Caplin to build our APIs in a way that is sympathetic to agile methodologies. One of the key problems with the iterative development of an API is how to…
Read MorePitfalls of Exception expectations in JsUnit
At Caplin we use the JsUnit framework to test our JavaScript code. Over time we have made minor modifications to it, integrating Mock4JS and JSCoverage, as well as adding a few of our own extensions that are sympathetic to our JavaScript coding style, however, by and large, our tests are…
Read MoreHow to dynamically create a class definition for use with Mock4JS
Mock4JS is a really useful unit testing helper library that allows you to create mocks of your JavaScript classes. What it doesn’t presently support is mocking of objects that you can’t create an instance of yourself using new Class() or of objects that are dynamically created and have functions appended…
Read More