Reputation: 1365
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.
Upvotes: 0
Views: 458
Reputation: 124469
I checked out the source code of your app on Github.
Your test_ip.rb
file defines class TestIp < Test::Unit::TestCase
, as it should. However, your test_dns.rb
file also defines class TestIp < Test::Unit::TestCase
, whereas it should define class TestDns
. Since that file also has def setup
, that setup method overrides the test_ip
one. This is why you see this error:
/home/dylan/dev/Murder-traffic/vendor/murder_traffic_server/tests/test_dns.rb:7: warning: method redefined; discarding old setup
/home/dylan/dev/Murder-traffic/vendor/murder_traffic_server/tests/test_ip.rb:7: warning: previous definition of setup was here
So, fix the class declaration in your test_dns.rb
file and everything should work.
Upvotes: 2