All posts in Unit Testing

I've just started using Observers in a Rails application I'm creating and found out that in order to have them picked up by rails you have to manually register the Observers within your environment.rb file, like so:

RUBY:
  1. config.active_record.observers = :my_observer

I like to have as much coverage for any code I write in Rails, such as associations I've created, validation rules etc. I'm not testing the validation itself (Rails' tests have that covered) what I'm testing is that I've actually applied the validation rule.

So I figured that I should do the same for the Observers which should be registered. I couldn't find any references to anyone else doing this so after a little bit of digging I've come up with the following approach for use with RSpec:
Continue reading this entry »

I've been doing quite a bit of unit testing on the Flex part of our new product lately and this has led me to fix a few issues and add some improvements to my FlexUnit Test Runner, I've been running with these fixes and improvements for a couple of weeks and finally took some time out yesterday evening to package them up so I could release them.

The key changes are:

  • Release has two downloads - one compiled to Flex 2.0.1 and one to Flex 3 - as it appears changes to Flex internals meant you couldn't use the Flex 2.0.1 compiled swc in a Flex 3 project.
  • Fixed: Issue where error thrown when no test results selected.
  • Fixed: Issue where resizing columns could cause the itemRenderer for the status to display horizontal scrollbar.
  • Added: Ability to choose whether to display test results live or wait until all tests complete (as displaying them live results in slower execution of tests, as it's constantly updating the UI) - this is saved as a preference.
  • Added: Ability to toggle display of the class path for the test case - this is saved as a preference.
  • Added: Test result details now extract Expected & Was from message string for failures and display in a manner that is easier to compare.
  • Changed: Test details now displayed on change rather than click event, to allow keyboard navigation of test results.

Head over to the FlexUnit Test Runner code page for all the downloads and to see the updated demo.

Sorry for the rather pointless post, I've just finished ensuring our test coverage is up to scratch on our project (as I mentioned in the last post). This means that I can get on with the next stage.

Which also means we're one step closer to releasing it.

Which also means I'm one step closer to being able to tell you all about it, ohhhhh it's so exciting!

The FlexUnit Custom Test Runner is a customised FlexUnit test runner which aims to improve the presentation and ease of use of running FlexUnit tests.

I have used unit testing in a few different languages, so obviously when I started using Flex I wanted to start off on the right foot by using unit testing from the outset. However after a couple of days using the base runner which is provided with FlexUnit I found myself spending a lot more time than I thought I should just looking for the details of the problem in the flex runner.

So as usual I attempted to make something that would work a little better for my requirements, see the FlexUnit Custom Test Runner code page find the full details and the download. As usual any comments should be made on the code page.

I'm currently in the middle of writing a reusable little JavaScript utility, which I'll probably release when it's finished, for one of my many projects and I wanted to employ unit testing as part of the development process, as I believe in the benefits of it quite strongly.

However my previous experience with unit testing JavaScript haven't been the most pleasent, I have tried the most common nUnit variations for JS, the best of which was JSUnit. But I always found this a little cumbersome and difficult to use, however I had recently read about the unit testing available with script.aculo.us and although the only documentation I could find was the PDF available at mir.aculo.us I thought I'd give it a go.
Continue reading this entry »

Updated the PHPUnit2 HTML Runner to apply a fix provided by Glen Ogilvie for the Formatter when it tries to find the original exception that was thrown.

I also tided the Formatter up a bit by adding much needed comments to explain the functionality it provides in the context of the HTML Runner.
Continue reading this entry »

I've recently started to get into using Test Driven Development in almost everything that I am able to because I've begun to really see and experience the benefits that it brings to development. The basic advantages of TDD are covered very well in an article by Robert Blackburn, Test Driven Development with ColdFusion Part I: An Introduction to Unit Testing so I won't cover them here.

I've been playing around with the xUnit family of testing frameworks in PHP, Coldfusion and JavaScript and really like the way they handle testing. However having been spoilt slightly by CFCUnit and JSUnit with their HTML GUIs I found the text runner in PHPUnit to be lacking for my needs.

So taking inspiration from the interface of CFCUnit I created the PHPUnit2 HTML Runner.