I am having following problem while running unit tests.
1. The test file contains:
require File.dirname(__FILE__) + '/../test_helper'
class RegionTest < Test::Unit::TestCase
I receive following error when running individual test
(./test/unit/region_test.rb):
./test/unit/region_test.rb: line 1: syntax error near unexpected token
`('
./test/unit/region_test.rb: line 1: `require File.dirname(__FILE__) +
'/../test_helper''
Prepare to smack your forehead. I get that running this:
$ sh test/unit/merchant_test.rb
test/unit/merchant_test.rb: 1: Syntax error: "(" unexpected
That's sh, meaning bash, not Ruby. Whatever runs your tests needs an explicit 'ruby' in it. That is the way of things.
Also, rake test:test:rcov or rake:test:units:rcov is failing with error
as,
Command failed with status (1): [/usr/bin/ruby
"/home/carlos/mytopics/...]
Dunno - do you have rcov, whatever that is, installed?
In theory, you should be able to run just one test suite with
ruby test/unit/role_test.rb
However, the Rails 2 generator f---ed that up; no idea why. The maintainers were formerly very good at keeping the tests flexible.
But...
Carlos Santana wrote:
However doing rake test:units still fails and so does rake:test:test:rcov or rake test:units:rcov.
I think those rcov things are a test coverage issue. If you use TDD you should not need them.
The error with rake test:units is:
rake aborted!
Command failed with status (1): [/usr/bin/ruby -Ilib:test "/usr/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake/rake_test_loader.rb" "test/unit/role_test.rb" "test/unit/attachment_test.rb" "test/unit/section_test.rb" "test/unit/region_test.rb" "test/uni...]
Did you try rake test:units --trace ? or is this its output?
Try this rake_test_loader.rb thing on each test suite.
In theory, you should be able to run just one test suite with
ruby test/unit/role_test.rb
However, the Rails 2 generator f---ed that up; no idea why. The
maintainers were
formerly very good at keeping the tests flexible.
But...
Carlos Santana wrote:
However doing rake test:units still fails and so does
rake:test:test:rcov or rake test:units:rcov.
I think those rcov things are a test coverage issue. If you use TDD you
should
not need them.
The error with rake test:units is:
rake aborted!
Command failed with status (1): [/usr/bin/ruby -Ilib:test
"/usr/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake/rake_test_loader.rb"
"test/unit/role_test.rb" "test/unit/attachment_test.rb"
"test/unit/section_test.rb" "test/unit/region_test.rb" "test/uni...]
Did you try rake test:units --trace ? or is this its output?
Yeah, this is the output of rake test:units --trace
Try this rake_test_loader.rb thing on each test suite.
Its working if I specify ruby and also with rake_test_loader.rb
(/usr/bin/ruby -Ilib:test
"/usr/lib/ruby/gems/1.8/gems/rake-0.8.2/lib/rake/rake_test_loader.rb"
test/unit/user_test.rb) specified.
The rake test is also working. Damn.. I really need code coverage
stats..
Any help please? I will send u free Jam CD..
However, there is significant difference between code coverage shown by rake test:test:rcov and rake test:units:rcov. The later one seems to be more accurate though.
I can't tell from your posts if all the tests run!
Coverage is an advanced topic, and it's utterly irrelevant if you have a broken build. Do you still have any symptoms to report?
I have never used rcov (and my test to code ratio is usually 2:1), so I feel compelled to recommend you get on rcov's mailing list for specific questions about it.
A thinking-out-of-the-box suggestion; can you manually identify lines of code, or branches, that are not tested? That research would help you out with rcov's mission statement - better coverage!