Cucumber formatter for unused steps

As time goes on in a project using cucumber you’ll end up with some steps which no longer get called, and you probably want to delete them. Annoyingly, there isn’t a built-in formatter you can use to find out where they are. Sure, the ‘usage’ formatter prints off unused steps, but it prints off all the other steps too! What’s needed is a formatter that will hunt down all steps that are not being used and then print off each step’s name and its location (file location and line number).

What follows is a very basic cucumber formatter that will do just that. To use it, copy the code into a file called ‘unused.rb‘ in your ‘features/support‘ folder and then use the formatter when you run cucumber:

cucumber -d -f Cucumber::Formatter::Unused

or

cucumber -d -f Unused

Silencing Log4Net in White Automation

The BBC Journalism WPF app is currently tested by a suite of bewildr tests. Sadly we also have a bunch of legacy tests written using White which we have to monitor. As anyone who uses it knows, White has a habit of dumping logging messages everywhere due to its use of log4net. An example:

Log4Net not configured. Looked for file: D:\...\...\log4net.config
Using RecheckDurationInMilliseconds=100 for Bricks/Bricks

There are hints on the white website that try to help out with silencing the log messages, but they don’t work. What’s needed is a vicious butchering of the log messages; and here’s how it’s done:

  1. Create a file called log4net.config in your project root
  2. Set the file contents to the following:

<log4net threshold="OFF" />

That will silence log4net – no more will filth be spewed all over the console!

Bewildr and IronRuby 1.1.2

—UPDATE—

All better now. Bewildr 0.1.11 has just been released that works with IronRuby 1.1.1 and the new 1.1.2.

The problem was this: IronRuby 1.1.2 implements Ruby 1.9.2, while IronRuby 1.1.1 implemented ruby 1.8.6.  Calling .select on a hash in 1.8.6 resulted in a 2D array (daft), whereas doing the same in 1.9.2 returns a new hash. The fix was just to check what version of ruby is being run and if it’s 1.8.6, flatten the result of the .select method, and convert it to a hash. Nice and easy.If it’s 1.9.2, do nothing – it already does what I want.

This exercise also demonstrated the value of automated tests – put in the fix, run the tests in IronRuby 1.1.1. It still works. Flip to 1.1.2 and run the tests again… they all work too. Commit, tag, push the changes, push the new gem version. Done!

gem update bewildr

—Original Post—

Bewildr is not compatible with IronRuby 1.1.2.  I’ll be releasing an update shortly, but for now, stick with IronRuby 1.1.1.

If you’ve installed 1.1.2, you’ll get the following error:

undefined method `flatten' for {:id=>"my_button"}:Hash (NoMethodError)
./lib/bewildr/finder.rb:20:in `condition_for'
./lib/bewildr/element.rb:102:in `get'

I’m on it.

Bewildr 0.1.10

Bewildr development marches on…

For this release there isn’t much new functionality, just the .height and .width methods on Element. There are a couple of bug fixes too. The main reason that this version has come to be is that after making a small tweek to how elements are built, useful rdoc can now be provided! rdoc.info has already gobbled up the code and produced some nice doco. Check it out here:

http://rubydoc.info/gems/bewildr/0.1.10/frames

It’s time to…

gem update bewildr

Ruby in NetBeans is no more…

First, Apple said they’re no longer supporting Java on the Mac platform, and I feared for NetBeans’ life… “Oh no! The carpet is being pulled from under my favourite Ruby IDE’s feet! How will it survive?”. Well, it turns out that Oracle answered that question for me. Due to “limited engineering resources” (Oracle’s only a small company – worth a mere US$161bln, a trifling sum) Ruby is no longer supported. NetBeans Ruby edition is no more as of NetBeans 7.

There has been a lot of angry talk bemoaning some of the actions taken by Oracle after they bought Sun. I generally stay clear of heated debate – I’ve got work to do :P – but I’m taking the cold-blooded murder of Ruby in Netbeans personally. Oi! Larry! Just who do you think you are!? I *like* coding Ruby in NetBeans and now I can’t any more! Try not to screw up anything else please!

I can put it off no longer, I’m going to have to learn vim. Wish me luck.

Bewildr 0.1.9

I’ve just pushed the latest version of bewildr: v0.1.9. New in this release:

  • Bewildr::Application now has proc_id and name methods to return the process ID and the process name
  • A new Bewildr::Mouse class to wrap the old BewildrClickr dll
  • Drag and drop – see here for examples (with thanks to Neil Danson!)
  • Toggle buttons now have toggle_on and toggle_off methods

Next step:

gem install bewildr

Note that there is now a dependency on ActiveSupport >= 3.0