5. Testing
5.1 Test your Objective-C components with Test::Unit
This will be obvious to experienced Rubyists, but it is worth mentioning: the Ruby access that we have to our Objective-C classes makes it much easier to test them.
Although there are more elaborate alternatives, I have been very happy using Test::Unit to write my tests and using Rake to run them. For an example, here’s a simple test of a C parser:
test_c.rb [ruby]
require 'test/unit' require 'rubygems' require 'objc' require 'CParser' class TestCParser < Test::Unit::TestCase def test_basic ObjC::CParser.parseFile_("test/examples/test.c") with ObjC::CParser.file do |file| assert_equal(1, file.functions.count) assert_equal(10, file.functions[0].statements.count) end end end
Did you find an error? Is something missing? Post your comment or suggestion below!
Comments (0) post