[MacRuby-devel] Unit testing in Xcode

Eloy Duran eloy.de.enige at gmail.com
Sat Apr 4 04:45:05 PDT 2009


No definitely not. This is Ruby, so we can do better ;-)

I have not yet finished porting Rucola to MacRuby, as of yet MacRuby  
is not mature enough to run some code we have on RubyCocoa yet.  
However, the port process was started, especially on our test case  
helper, so this might currently work good enough for you.

The current test case code is in: http://github.com/alloy/rucola/blob/macruby/lib/rucola/test_case.rb

If you'd like to add test/spec to the mix, there were some extra  
workarounds needed (not sure if it's still the case with test-spec  
0.10): http://github.com/alloy/rucola/blob/macruby/lib/rucola/test_spec.rb

For an example of a controller test see: http://github.com/alloy/webapp-app/blob/34e270667f34046bdf3379cd124788825dd59e8b/WebAppGenerator/test/controllers/test_application_controller.rb
And a model test: http://github.com/alloy/webapp-app/blob/34e270667f34046bdf3379cd124788825dd59e8b/WebAppGenerator/test/models/test_web_app_bundle.rb

Note that test/spec wraps around regular old test/unit. Example:

describe "Foo" do
   it "should exist" do
     lambda { Foo }.should.not.raise NameError
   end
end

Is the equivalent of:

class FooTest < Test::Unit::TestCase
   def test_foo_exists
     assert_not_raise(NameError) { Foo }
   end
end

I'm sure it can be hard to understand some parts, so let me know when  
in doubt.

Eloy

On 4 apr 2009, at 11:39, Frisco Del Rosario wrote:

> Is unit testing in Xcode necessarily as cumbersome as it seems to be  
> described in http://developer.apple.com/documentation/developertools/Conceptual/UnitTesting/Articles/CreatingTests.html 
>  ?
>
> Xcode is making me miss the days I could just append a TestCase  
> instance with TextMate and hit command-r.
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel



More information about the MacRuby-devel mailing list