내 테스트가 실행되지 않는 이유를 잘 모르겠습니다. calc.rb 파일에 포함 시키면 작동합니다. 그러나 테스트를 나눠서 test_calc.rb에서 실행하려고하면 파일이 실행되지 않습니다. 그리고 다음과 같은 오류가 발생합니다 :왜 내 테스트가 효과가 없습니까?
/.rvm/rubies/ruby-2.1.4/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from test_fall.rb:6:in `<class:TestAdd>'
from test_fall.rb:4:in `<main>'
나는 2.1.4 디렉토리에서 파일을 찾고있는 이유를 잘 모르겠습니다.
calc.rb
class Calc
def add(a, b)
a + b
end
end
test_calc.rb
require 'calc.rb'
require 'minitest/autorun'
class TestAdd < Minitest::Test
def test_add
calc = Calc.new
expected = calc.add 3,2
assert_equal expected, 5
end
def test_add_bigint
calc = Calc.new
val = calc.add 10000000, 10000000
assert_equal val, 20000000
end
end
'require'는 작업 디렉토리를 포함하지 않습니다. 아마도'require_relative'를 원할 것입니다. http://stackoverflow.com/q/3672586/1569 –
고마워요! 도움이됩니다. – Kozmo101