Ruby Test Integration With CruiseControl.net
Please use the thread Integrating Ruby On Rails Unit Tests in CruiseControl.net
for posting comments about this procedure.
In order to integrate your ruby on rails unit tests into your CruiseControl build process so you can see the test results in the webdashboard, you must peform the following tasks in order:Installing Test-Report:
- Download and extract the contents of the test-report-0.3.0.zip (looks like the rubyforge project vaporized so I uploaded a copy that I had) Version 0.3.0 distribution.
- Open the folder where you saved the test-report code.
- Modify the /lib/test/unit/ui/reporter.rb, and add the following snippet just beneath the other 'require' declarations.
Setting up WebDashboard:
- Open a command prompt in the test-report root directory.
- Execute > ruby.exe setup.rb config
- This command configures the test-report addin to work with your installation of Ruby.
- Execute > ruby.exe setup.rb install
- This command adds the test-report files to your ruby library.
- Download rubyunittests.xsl and save it to your CruiseControl.NET/webdashboard/xsl/ folder.
- Now you must change your CruiseControl.NET/webdashboard/dashboard.config file so it will show a new RUnit Details report in the Dashboard's left navigation.
- Open the dashboard.config file and modify it by adding your own "xsl report build plugin".
<!-- Example From File: /CruiseControl.NET/webdashboard/dashboard.config -->
<!-- This is where you insert the following line -->
<xslReportBuildPlugin description="RUnit Details" actionName="RunitBuildReport"
Configuring Your tests.rb File:
Setting up Your Build Script:
- Download tests.rb and save it to the root of your Ruby On Rails application.
- The tests.rb sample file assumes a pattern of /tests/unit//*_test.rb, you will need to change this pattern or add your own methods for adding functional tests or other tests directories you wish to generate results for.
- Don't forget to modify the tests.rb file for your specific database configuration, specifically the createDatabase method. This example file assumes SQL Server 2005.
- Note: To configure different databases, look at the Ruby Active Record source code located in your c:/ruby/lib/ruby/gems/1.8/gems/activerecord-x.x.x/lib/activerecord/connectionadapters/. Specifically, look at the adapter_name property for the connection adapter your application requires.
- Add a build task in your build.myproject.xml MSBuild script file as show below, this will execute the unit tests.
<!-- Run Ruby Unit Tests -->
<Exec ContinueOnError="false" Command="c:\ruby\bin\ruby.exe tests.rb"
<Output TaskParameter="ExitCode" ItemName="ExitCodes"/>
<Error Text="One or more Unit Tests failed." Condition="'%(ExitCodes.Identity)'>0"/>
- In the build script for your project, add a file merge publisher. This will merge your unit test output details into the cruise control build log for your project.
- Note: You can change the name of the output results xml file by changing the name of your TestSuite class's constructor where it calls the base class's initialize('MyRailsApp') argument, located in tests.rb.
<!-- Some Build Script Settings -->
<!-- Some Other Build Script Settings -->
(added local copy because rubyforge site is gone!)Links:
Test-Report Version 0.3.0 - http://test-report.rubyforge.org
(site is down or does not exist anymore)
Throughworks CruiseControl.Net - http://cruisecontrol.confluence.net