如何在Windows上使用Eclipse在Ruby中對以下代碼段進行TDD操作?如何在Windows上使用Eclipse的Ruby中的TDD
class PassIntegers
def addition(i,j)
k = i+j
end
end
如何在Windows上使用Eclipse在Ruby中對以下代碼段進行TDD操作?如何在Windows上使用Eclipse的Ruby中的TDD
class PassIntegers
def addition(i,j)
k = i+j
end
end
通過執行gem install test-unit
運行下面的代碼片斷作爲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
可能的問題安裝測試單元
如果在Eclipse控制檯出現以下錯誤:
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)
打開C:\dev\tools\eclipse\configuration\org.eclipse.osgi\bundles\965\1\.cp\testing\dltk-testunit-runner.rb
和評論
#autoRunner.output_level = Test::Unit::UI::SILENT
並添加
autoRunner.runner_options[:output_level] = Test::Unit::UI::Console::OutputLevel::SILENT
解決這個問題,並再次運行測試。
方案來解決問題uninitialized constant Test::Unit::UI::SILENT (NameError)
在http://blog.christopherkaiser.de/?p=319
在Eclipse MARS,解決同樣的錯誤我評論線252('autoRunner.output_level =測試::單位:: UI :: SILENT') –
發現的Windows和Eclipse有什麼用它做。我會開始像寫更容易測試的東西,現在你不得不打印或更改標準輸出。 –
感謝您的反饋。我修改了這個問題。 – 030
並公佈答案 – 030