Question

How to TDD the following snippet in Ruby using Eclipse on Windows?

class PassIntegers
  def addition(i,j)
    k = i+j
  end
end
Was it helpful?

Solution

Install test-unit by executing gem install test-unit

Run the following snippet as 2 Ruby Test

require 'test/unit'

require 'PassIntegers'
class TestPassIntegers < Test::Unit::TestCase
    def test_pass_integers
      passIntegers = PassIntegers.new
      expected = passIntegers.addition 3,2
      assert_equal expected, 5
    end
end

ruby-test-eclipse

Possible issue

If the following error occurs at the Eclipse Console:

C:/dev/tools/eclipse/configuration/org.eclipse.osgi/bundles/965/1/.cp/testing/dltk-testunit-runner.rb:252:in `block in <top (required)>': uninitialized constant Test::Unit::UI::SILENT (NameError)

Open C:\dev\tools\eclipse\configuration\org.eclipse.osgi\bundles\965\1\.cp\testing\dltk-testunit-runner.rb and solve this by commenting

#autoRunner.output_level = Test::Unit::UI::SILENT

and adding

autoRunner.runner_options[:output_level] = Test::Unit::UI::Console::OutputLevel::SILENT

and run the test again.

Solution to solve the uninitialized constant Test::Unit::UI::SILENT (NameError) issue found at http://blog.christopherkaiser.de/?p=319

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top