I feel silly for asking this, but how do I start unit testing with
Rake?
I'm just getting started setting up unit tests and learning about it,
but my googling hasn't turned up any straightforward "getting started"
tutorials for running my unit tests with Rake.
I've set up a few simple unit tests to start with and I'm not sure how
to actually run them. I see reference to just running "rake" or "rake
test:units" but those don't seem to run my tests. What more do I need
to do?
I've set up a few simple unit tests to start with and I'm not sure how
to actually run them. I see reference to just running "rake" or "rake
test:units" but those don't seem to run my tests. What more do I need
to do?
Post some code; you might have the test declared wrong.
rake alone will run rake test
Where are your unit tests? Are they in the test/*/ folders where the
rake test task expects them?
Would this run them?
ruby test/unit/my_model_test.rb
The Agile Web Development with Rails book laid all this out, if I
recall correctly. But that was a long, long time ago in Rails-time.
Last month, I think...
progressions wrote:
> I've set up a few simple unit tests to start with and I'm not sure how
> to actually run them. I see reference to just running "rake" or "rake
> test:units" but those don't seem to run my tests. What more do I need
> to do?Post some code; you might have the test declared wrong.
rake alone will run rake test
Where are your unit tests? Are they in the test/*/ folders where the
rake test task expects them?
I haven't done much of anything to the tests. They're right where they
should. I'm trying to run test/unit/comic_test.rb (from the model
"comic") and it does nothing.
...I tried putting a "puts" statement in the comic_test.rb file to
verify that it would run at all, and it does. But the testing engine
doesn't seem to get invoked at all.
The Agile Web Development with Rails book laid all this out, if I
recall correctly. But that was a long, long time ago in Rails-time.
Last month, I think...
I'm definitely planning on getting the second edition when I can, but I
don't have it yet.
Tests work by inheriting a class that registers each of its children in a test runner. You might try 'Test::Unit' or 'Test::Rails' there - I seem to recall the 'Rails' might be from one of my plugins.
If that doesn't work, write a new source file with only this in it:
require 'test/unit'
class TestAnything < Test::Unit::TestCase # "it has come to this" --Poo...
def test_anything
assert false
end
end
If you can't get that working, post to the Ruby newsgroup, and work your way back to Rails!