I have Rakefile in my project.
mt_server_dir = File.expand_path('vendor/murder_traffic_server')
Rake::TestTask.new("test_vendor") do |t|
chdir mt_server_dir
t.libs = [mt_server_dir]
t.test_files = Dir["#{mt_server_dir}/tests/test_*"]
t.warning = true
end
When I run tests
rake test_vendor
First test in the list, always fail.
With error.
test_ip.rb:55: warning: instance variable @ip not initialized
That is mean, not execute setup method in first test.
When I run test directly.
ruby test_ip.rb
Test is successful.
I tried rename first test to test_zip.rb, and when I running test through rake, test is successful, but first in the list test test_dns.rb is failed.
Who know how fix it?
Thanks.
I checked out the source code of your app on Github.
Your
test_ip.rbfile definesclass TestIp < Test::Unit::TestCase, as it should. However, yourtest_dns.rbfile also definesclass TestIp < Test::Unit::TestCase, whereas it should defineclass TestDns. Since that file also hasdef setup, that setup method overrides thetest_ipone. This is why you see this error:So, fix the class declaration in your
test_dns.rbfile and everything should work.