progressions-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-26 22:58 UTC
Starting unit testing with Rake?
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? Thanks in advance, Jeff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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? 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... -- Phlip http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
progressions-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-27 03:45 UTC
Re: Starting unit testing with Rake?
On Jan 26, 8:13 pm, Phlip <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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.> Would this run them? > > ruby test/unit/my_model_test.rbThis doesn''t do anything: C:\rails\comics\trunk>ruby test/unit/comic_test.rb C:\rails\comics\trunk>ruby test/unit/comic_test.rb C:\rails\comics\trunk> ...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.> -- > Phlip > http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!Thanks for the help. Jeff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
progressions wrote:> This doesn''t do anything: > > C:\rails\comics\trunk>ruby test/unit/comic_test.rb > > C:\rails\comics\trunk>ruby test/unit/comic_test.rbStart with the obvious stuff. Your ''puter is turned on, and ''ruby -v'' prints Ruby''s version, right? Next, the first 5 lines of your test should look like this: require File.dirname(__FILE__) + ''/../test_helper'' class ChatTest < Test::Rails::TestCase def test_something assert false end 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! -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
progressions-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-27 04:58 UTC
Re: Starting unit testing with Rake?
Hm. I''m guessing this line I put in my environment.rb might have something to do with it? Test::Unit.run = true :) Was advised to put that in because it was running tests on my production server and forgot about it til now. Sorry about that! Jeff On Jan 26, 10:16 pm, "Phlip" <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> progressions wrote: > > This doesn''t do anything: > > > C:\rails\comics\trunk>ruby test/unit/comic_test.rb > > > C:\rails\comics\trunk>ruby test/unit/comic_test.rbStart with the obvious stuff. Your ''puter is turned on, and ''ruby -v'' prints > Ruby''s version, right? > > Next, the first 5 lines of your test should look like this: > > require File.dirname(__FILE__) + ''/../test_helper'' > > class ChatTest < Test::Rails::TestCase > > def test_something > assert false > end > > 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! > > -- > Phlip > http://www.greencheese.us/ZeekLand<-- NOT a blog!!!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---