Showing posts with label cucumber. Show all posts
Showing posts with label cucumber. Show all posts

Sunday, March 06, 2011

Cucumber DSL for Selenium Testing - Take 2

After poking around with Cucumber, Cuke4Duke and Selenium, I liked what I saw and started digging around for more interesting bits. I have moved from selenium 1 to Webdriver(Selenium 2).

One of the minor problems I have had so far is that the browser windows don't get closed after my tests completed.

I saw a number of attempts at solving this including having a tagged @After hook on the last scenario in the last Feature. None of them really jumped out at me until I read a question to the group and that led me to give a JVM shutdown hooks a go (equivalent to Kernel#at_exit in Ruby land). That seems to work quite well and lives well away from the features and steps making for cleaner code. It also means that we will have a clean suite of features that don't get polluted by technical detail.


Do take a look at the full thing on GitHub. Let me know what you think.


Tuesday, March 01, 2011

Cucumber DSL for Selenium Testing - Take 1

I have had a few hours to play with Cucumber tests using cuke4duke by Aslak Hellesøy, a very useful addon to Cucumber which makes it possible to write step definitions in several JVM languages. I have gotten it to the point where I can write Cucumber Features and Scenarios for very basic tests. I hope to write in more detail about my full findings and thoughts later on.

I have set it up so that it can be built in Maven. The pom.xml file can be located here. The project structure is pretty simple and can be structured as follows:



|-features
|-brandhub.feature (source can be found here
|-src
|-test
|-java
|-sample
|-BrandHubSteps.java (full source can be found here)
|-pom.xml (source can be found here)



All you then need to do once you have the above structure is run mvn clean integration-test and you should be on your way. Your test results can be found in target/surefire-reports. I have included html and junit reports. You will also find that there is a pretty console log of your features and your scenarios.

Please note that the first time you run you will need to append the following system property to your maven command line:

-Dcucumber.installGems=true

This will make sure that the cuke4duke Ruby gem and its dependencies are installed. If you don't do this, you will most definitely get an error along the lines of:

Error opening script file: /.jruby/bin/cuke4duke

Let me know what you think.

Peace and Love.