Archive for the ‘technology’ Category

Readable Selenium tests with rspec

Tuesday, December 4th, 2007

A few months back, I converted a large set of ruby selenium tests to using selenium-rc and rspec. Unfortunately the changes didn’t stick, mainly due to a lack of ruby debugging support in our primary development environment, Intellij 6. The idea has stayed at the forefront of my mind since that time and it was great to stumble upon Kerry Buckley’s blog on selenium-rc and rbehave. In my opinion, the type of approach to testing that he discusses is an absolute necessity if we expect automated functional testing to go mainstream.

Random humour

Sunday, October 15th, 2006

You would not be alone in thinking that a blog entry on Bruce Schneier’s blog talking about a book with the title A Million Random Digits with 100,000 Normal Deviates published by the Rand Corporation in 1955 would be likely to put you to sleep. In this instance however, Bruce’s recommendation to check out the comments for this book on Amazon will surely prove you wrong.

Using Joda Time to ease testing

Wednesday, September 27th, 2006

I would consider it a rarity for a business system not to make use of dates for some reason or another. Using the standard date libraries with the JDK is just a pain, one that I would prefer not to deal with. Fortunately, my current project team selected the Joda Time library as a replacement for java.util.Calendar, java.util.Date and theassociated parsers, formatters, etc available in the JDK. Beyond the ease of use of this library has compared to the standard API, our choice was further justified recently when we were asked to introduce a function to set the system time for testing purposes. Simply put, Joda Time allowed us to add this functionality without having to change any of our existing code.

To illustrate the ease of adding this functionality to our system, the following code is what is normally required to get the current system date:

\tYearMonthDay today = new YearMonthDay();

Adding the ability to change the date of our application (without actually changing the system clock) does not require a change to the above code. Instead a simple utility class has been provided in the Joda Time library, DateTimeUtils. By calling either setCurrentMillisFixed or setCurrentMillisOffset it is possible to change the date/time that the default YearMonthDay constructor uses for its internal state. DateTimeUtils.setCurrentMillisSystem can be used to restore the default bahaviour of using system clock to determine the value for the YearMonthDay default constructor.

Using windows.location.hash to persist client state in Ajax applications

Monday, September 4th, 2006

Just came across a couple of good references on storing browser state using windows.location.hash in Javascript. This allows Ajax applications to be Refresh and Back compatable.

Aptana

Thursday, August 24th, 2006

I’ve only just stumbled across the Aptana Web IDE. It’s basically a Javascript IDE using the Eclipse platform. The screenshots look nice and the fact that it has code assist and Javascript reference documentation built-in means it is well worth a look (this weekend perhaps).

Upgraded to Typo 4.0.0

Sunday, July 30th, 2006

Spent some time today on getting Typo 4.0.0 up and running. The first step, migrating the rails database and getting the site on line took less than half an hour this morning. I have had to change my theme for now, but I’m not too cut up about that.

The only thing that made the upgrade take longer was in relation to errors I was receiving when attempting to post blog entries. The problem was caused when attempting to post an article to the blog. In the background, typo performs an update on the sessions table, which was failing due to a lost connection with the MySQL database used as Typo’s datastore. There were two things that appeared to have helped in resolving this.

  1. Installing the Ruby MySQL native driver (that was taken care of exceptionally quickly by the staff at A Small Orange)
  2. Reducing the verification timeout in active record to 10000.

To change the verification timeout, add the line:

ActiveRecord::Base.verification_timeout = 10000

to your config/environment.rb file.

Update: There still seem to be some problems with lost connections, I will update if I can manage to work it out.

Ruby on Rails support in Intellij 6

Monday, July 24th, 2006

It looks like JetBrains are working on an open source Rails plug-in for the next release of IntelliJ. This sounds like it could be good news, but I think it is best to refrain from hailing this as a great new feature for IntelliJ until I see it in action.

Typo 4.0.0

Sunday, July 23rd, 2006

I am very excited to see that Typo 4.0.0 has just been released. Congratulations to the Typo team on getting this out and thanks for all the hard work.

Hopefully I will have this site up and running this new version over the next few days after running it through its paces at home.

By the way, I am back from my three week vacation. More on that shortly.

IDE Feature Request: The Yagni Development Assistant

Wednesday, May 24th, 2006

Integrated Development Environments are constantly evolving, but I have noticed that many are reaching a level of maturity that signifies a need for them to begin introducing questionable features to enable them to continue to display long term viability. For this reason, I think it is time that IDE’s such as Netbeans, Eclipse and IntelliJ look to introduce a variation on Clippy the Microsoft Office Assistant to help developers to write better code.

While pair programming helps you to write high quality code in an efficient manner there are times that a pair of programmers will end up going off on a tangent and working on something that ultimately ends up not being necessary. To counter the unbridled enthusiasm that usually causes this to occur I give you Yagni, the Development Assistant.

Yagni’s role within the IDE is to monitor a developer’s work and provide warnings and advice about bad practices and code smells. As seen below, Yagni pops up when a class is being written before the corresponding unit test.

Yagni can also step in when it thinks that you have gone off track for too long working on a development spike and try to convince you to move back on the task of writing production code.

The code intelligence of Yagni is extensive to ensure that you don’t go off track and start writing code for framework, one of the most common time wasters in software development. Here Yagni steps up and reminds you in no uncertain terms that:

Sadly, Yagni is still a work in progress so please feel free to provide some comments as to what Yagni should do to make your coding experience more fruitful. Alternatively, there might be other IDE assistants that you can think of; one example that I can think of is Microsoft Development Mentor. In the case of Microsoft Development Mentor, maybe he could sit around waiting for you to write application logic in standard code and suggest that you write it in a stored procedure instead, with a goal of helping you to keep your code difficult to understand and maintain. There is no doubt that the opportunities are endless…

Ant Strategy 03: Clearly define top level targets

Thursday, May 11th, 2006

When you invoke ANT from the command line, you can specify -projecthelp or -p as part of your ANT call. By adding one of these options to the command line, you will receive a list of all targets that have a description attribute defined. Often, these types of targets are referred to as top level targets. These are targets that have all of their dependencies defined and can typically be run without any issues.

Top level targets can depend upon other top level targets, but typically they will depend upon lower level targets that do not have a description or their dependencies properly defined. These low level targets do not normally define their dependencies as this creates to much of a burden on the author of the build script when adding and removing new/old targets.

When creating a new build script, I find it beneficial to define all top level targets in the same section of the file. To increase readability of the build script and to keep the intention of the build clearly defined, all top level targets should have no nested tasks within their body instead relying on the element’s depends attribute to define the implementation for each target. For example:

  <target name="build"      depends="init-build, build-compile"      description="Target to compiles all production source."/>

By following this strategy consistently it is possible to change the way a build works quickly and easily without getting bogged down in implementation details.

A common exception to this strategy is the implementation of a clean top level target. As the clean target usually has a simple implementation, I will often define a clean target at the end of my top level targets like the one below:

  <target name="clean"      description="removes the build and dist temporary directories and any files found within.">    <delete dir="${build.dir}"/>    <delete dir="${dist.dir}"/>  </target>