Ruby On Rails, Design, Simplicity, Web 2.0, Ajax, Mac and Tons of Pizza.

Apr 22

Selenium and CruiseControl.rb

Posted by Sandro Paganotti in Ruby on Rails - no comments digg this add to delicious

Within the project we’re developing we found ourselves pretty attracted from the features offered by Selenium so we started to use its beautiful IDE to create behavioral tests that try to ensure our quality requirements.

But soon we discovered that manually aggregating and running these tests often lead to problems: first of all you don’t really have the same data on your developer instance each time you run Selenium so it happens that a particular business object is no more present or has been already, let’s say, processed and that means failure.

So we decide to move all the test we created to our CruiseControl.rb instance. To do that we followed these steps:

  • Create a Selenium startup script by following this good post from Mohammed Morsi;
  • Save your Selenium IDE tests as Unit Test File (File > Export Test Case As.. > Ruby) and copy them under your application tests/unit directory;
  • Put this piece of code within your ‘custom_cc.rake’ file

      begin
        puts "="*10 + "SELENIUM TESTS" + "="*10
        Kernel.system "ruby","script/server","-d","-e","development","-p","3000" 
        CruiseControl::invoke_rake_task 'test:units'
      rescue => e
        @test_errors << e
      end
        Kernel.system "killall","ruby" 
      end

That’s all! Hope you’ll find it useful !

Post a comment

Categories:

Tags:

Powered by Mephisto, Valid XHTML 1.1, Valid CSS - Supported by Wave Factory