NUnit/Watir/Ruby Test Integration
Travis Illig took my NUnit/Watir integration POC and ran screaming down the street with it and has released his code on CodeProject. There are also some other integration projects in a similar vein going on that I'll post about later.
Travis' solution is clever in it's use of attributes. It does everything automatically that I did manually with resource extraction. The easiest way to grok it is to look at a sample NUnit test you'd write:
using System;
using NUnit.Framework;
using RTE = Foo.RubyTestExecutor;
namespace Foo.Test
{
[TestFixture]
public class RubyTestExecutor
{
[Test(Description="Verifies you may run standard NUnit-only tests.")]
public void NUnitOnly_NoRubyAttrib()
{
Assert.IsTrue(true, "This NUnit-only test should always pass.");
}
[RubyTest("Foo.Test.Scripts.RubyTest.rb", "test_Valid")]
[Test(Description="Verifies a valid Ruby test will execute.")]
public void RubyTest_Valid()
{
RTE.ExecuteTest();
}
[WatirTest("Foo.Test.Scripts.WatirTest.rb", "test_Valid")]
[Test(Description="Verifies a valid WATIR test will execute.")]
public void WatirTest_Valid()
{
RTE.ExecuteTest();
}
[RubySupportFile("Foo.Test.Scripts.supportfile.txt",
"supportfile.txt")]
[RubySupportFile("Foo.Test.Scripts.SubFolder1.supportfile1.txt",
@"SubFolder1\supportfile1.txt")]
[RubyTest("Foo.Test.Scripts.RubyTest.rb",
"test_RubySupportFile")]
[Test(Description="Verifies Ruby support files can be extracted.")]
public void RubySupportFile_Valid()
{
RTE.ExecuteTest();
}
}
}
It's the ExecuteTest() of course that does all the heavy lifting by walking the call stack looking for Attributes and acting on them. Check out his article and get involved.
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter

If you're using a blog engine like DasBlog you likely already have this, however, if you've added to or modified a theme you might want to confirm that your theme HTML contains this autodiscovery info. You can just hard-code it in the main blog template's, there's no harm.
I'm still using