Latest Updates: Unit Testing RSS

  • The beauty of small tests

    Andrew Darnell 12:53 pm on 15th April, 2010 | 0 Permalink | Reply
    Tags: , , , , , Unit Testing

    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 expectation, but fundamentally, it pin-points the cause of the failure to a small target, which usually means that debugging becomes trivial.

    When an end to end acceptance test fails, the failure could be due to any one of a large number of source lines or expectations changes across a large body of code.  Debugging may be quick, but often isn’t.

    (More …)

     
  • Agile – Tests = Fragile

    Andrew Darnell 3:55 pm on 9th April, 2010 | 0 Permalink | Reply
    Tags: , , , , , Unit Testing

    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, categorically will fail!

    There are two sets of tests that are critical here…

    Good unit test coverage and a TDD approach to development ensure that the rest of the organisation is supplied with product that works as developers expect it to.

    Component tests and functional acceptance tests ensure that the product does what the product owner expects it to.

    • Practically, the only way to do solid testing on new features is to have a stable product.
    • Practically, the only way to assure a stable product is to either have solid regression testing on each release or to not make any changes.
    • Practically, the only way to make sure that adequate regression testing is done is to automate the regression tests (unit, component, functional).

    Without these tests in place, iterating quickly places an impossible to meet burden of verification demand on the testers and product owners, which just gives you a fragile process not an agile one.

    Is your process Agile or Fragile?

     
  • Testing APIs for Backwards Compatibility

    Ian Alderson 5:07 pm on 19th February, 2010 | 0 Permalink | Reply
    Tags: , , Unit Testing

    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 ensure that it remains backwardly compatible. Although each new release of an API is focussed on providing more functionality, easier use, or increased robustness for its users, those same users want their existing code to continue working when they upgrade.

    This article addresses the issue of how to identify, with confidence, whether an API is backwardly compatible or not. As I mentioned previously there are times when an API is just too incorrect to be kept, however the decision for a breaking change must be a deliberate one – not an accidental one that is typically only discovered when the users of the API find that their existing code no longer works.

    (More …)

     
  • Pitfalls of Exception expectations in JsUnit

    Ian Alderson 12:00 pm on 29th January, 2010 | 2 Permalink | Reply
    Tags: , JsCoverage, , , , Unit Testing

    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 written using plain old JsUnit assertions.

    One of the main reasons we were keen to adopt JsUnit five years ago was its similarity to JUnit 3. Back then our developers had been using JUnit for a few years, and familiarity of the JsUnit API meant that we could immediately start writing tests. Unfortunately the old adage “familiarity breeds contempt” reared its ugly head, and we discovered that our main issue with JsUnit were the occasional, very subtle, differences between it and JUnit. The logic for a test that works in JUnit might not work in JsUnit.
    (More …)

     
  • How to dynamically create a class definition for use with Mock4JS

    Phil Leggetter 6:00 pm on 16th April, 2009 | 1 Permalink | Reply
    Tags: , , , , , , Unit Testing

    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 to them.

    (More …)

    Related Posts with Thumbnails