Watir controller for NUnit just to integrate results of Ruby Test::Unit tests to CruiseControl.NET. It does good with NUnit results. So if we can run Ruby tests with NUnit, we have nothing more to do.

However, it would be good too to do without intermediate unit-testing code, if only Test::Unit runners could store there result in form of some common XML

..."> Ruby or Watir tests included in CruiseControl.NET - Издеваться над жуками! - BYTE-force columns
BYTE-force columns
Company news, team and friends.

Ruby or Watir tests included in CruiseControl.NET

Till now I am used to use the Scott Hanselman's Watir controller for NUnit just to integrate results of Ruby Test::Unit tests to CruiseControl.NET. It does good with NUnit results. So if we can run Ruby tests with NUnit, we have nothing more to do.

However, it would be good too to do without intermediate unit-testing code, if only Test::Unit runners could store there result in form of some common XML. And now it is done with use of Alexey Verkhovsky's Test::Unit::Reporter.

This is how the test-running Ruby script can look now:

# This part is all of old code to run tests.
# (It just picks all test cases from a directory — they start with "tc_")
require 'test/unit' 
Dir['tc_*.rb'].each { |testCase| require testCase }

# This is the new part to replace autorunner.rb which would start otherwise.
# It should save the resulting XML to a directory named "TestResults".
require 'XMLRunner'
XMLRunner::report_to 'TestResults'

My XMLRunner module now has just this code inside. It is all that is needed to make the Test::Unit::Reporter produce results in XML form:

require 'test/unit/ui/console/testrunner'
require 'test/unit/ui/reporter'
require 'stringio'

module XMLRunner

def XMLRunner.report_to(dir)
    ObjectSpace.each_object(Class) do |test| 
        Test::Unit::UI::Reporter.run(test.suite, dir, :xml) if
        test < Test::Unit::TestCase
    end
end

end

Thus, now we have XML files in JUnit result format. That is they can be directly used by any tool which works with JUnit test results.

And CruiseControl accepts them too! We just need to add a “merge” task in ccnet.config before the “xmllogger” task. Like this:

<merge>
    <files>
        <file>TestResults/TEST-TC_*.xml</file>
    </files>
</merge>

and we already will get all ruby test failures in a build report:

E-mail report

As far as I understood, the Reporter class is not included in standard Test::Unit and Ruby installations. So it should be downloaded separately from rubyforge.org and then installed.

The other drawback is that CC.Net does not have reports for JUnit test details and test timings. However, it does have them for NUnit. Of course, including Ruby test results through NUnit test was not informative either. But now, having a proper test result XML in a build log we could display much more information. So I think of the xsl-stylesheet for JUnit details report as a thing wich is good to have. And I will appreciate it if someone already have written one :O)


Posted Nov 29 2005, 03:04 PM by Yury Krasavin

Comments

TrackBack wrote CruiseControl
on 05-06-2006 0:34

CruiseControl is a framework for a continuous build process. There are implementations in Java and .Net.

TrackBack wrote Browser based testing with Watir - integrating into cruise control
on 05-06-2006 0:34
Browser based testing with Watir - integrating into cruise control
Todor Todorov wrote re: Ruby or Watir tests included in CruiseControl.NET
on 08-02-2006 19:12
Zdrastvui, bratu6ka!
:) Kak dela?
Could you please explain me if there are another things to change at the require ' ' stuff at the other Watir files?
I've done all the steps,that you've described,but my parser keeps blowing on ...
Is it also necessary to have set CruiseControl in order to start the major script for all the testings ?
Thank you in advance!
Bye
T Todorov wrote re: Ruby or Watir tests included in CruiseControl.NET
on 08-02-2006 19:28
...and could you explain me the paths in quotation marks at the require statements,that you have used . I think that this is the main problem for me.
Thank you one more time !
Bye
Yury Krasavin wrote re: Ruby or Watir tests included in CruiseControl.NET
on 08-03-2006 12:13
Privet, Todor!

No, theese scripts themselves have nothing to do with CruiseControl. They just produce result in xml rather than in plain text or gui form as conveintional.

Are you sure you had downloaded and properly installed separate Ruby library from the Test::Unit::Reporter link (http://test-report.rubyforge.org/)? It was it in the second require statement. Those paths should be found in lib\ruby\1.8 (or 1.9 already?) under your Ruby installation. Other two "requires" are standard files required by reporter. Indeed it's a reporters bug not to load them silently. Maybe a new version has fixed it. But 'require' works only first time it parsed, so one more wouldn't hurt.
Srinetra 121 wrote re: Ruby or Watir tests included in CruiseControl.NET
on 09-21-2006 13:20
If i want to ignore a particular column while asserting a row of a table then how i havvw to use assert_equal in Watir ?
Ex: I am using assert_equal("1","2","12-Sep-2006") the third column is always changing every day .How i can use the same assert_equal to ignore the assertion on the third column ?
Yury Krasavin wrote re: Ruby or Watir tests included in CruiseControl.NET
on 09-21-2006 14:50
Srinetra 121, 'assert_equal' takes 2 to 3 arguments, first of wich is expected value and second is the value to compare with.
I.e. if you want to compare parts of arrays, for example, you could use Ruby's ability to pass intervals to [] of an array:

   assert_equal( ["1", "2"], tableRow[0..1] )

where tableRow maybe ["1", "2", "12-Sep-2006"].

Although you may want to compare each element in a cycle. This way you may separate failure messages by elements they occur on.
Ayende @ Blog wrote Testing ASP.Net UI: WATIR Impressions
on 01-13-2007 12:20
Testing ASP.Net UI: WATIR Impressions
Copyright ©2004-2009 BYTE-force
Powered by Community Server (Non-Commercial Edition), by Telligent Systems