SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    intro to ruby unit testing (non-rails)?

    I'm a Ruby newbie using Ruby in Steel (Ruby inside Visual Studio IDE, though not a "Ruby.NET". I've made a little progress at starting unit testing with Test::Unit. I know enough about JUnit and NUnit to work out a lot of it.

    But I read somewhere on these forums that "TDD is HUGE" in teh Ruby community. Yet I've had trouble finding much beyond vague guidance on using Test::Unit.

    Your Resources section onthis forum ought to point any such out if they exist.

    thanks,

    Chuck

  2. #2
    SitePoint Addict myrdhrin's Avatar
    Join Date
    Jul 2004
    Location
    Montreal
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello Chuck,

    did you by any change look into the code base for ruby itself? If you look into the lib folder of your ruby installation you'll find (assuming you're using version 1.8) under ruby/1.8/test a file called unit.rb.

    This header of this file pretty much gives all the info you want to get started. It might not be a full step by step intro to TDD in Ruby but as you know Nunit and JUnit it should be enough to get you flowing the in the right direction.
    Jean-Marc (aka Myrdhrin)
    M2i3 - blog - Protect your privacy with Zliki

  3. #3
    SitePoint Enthusiast ianpurton's Avatar
    Join Date
    Jul 2004
    Location
    Isle of Dogs
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would recommend taking a look at <ahref="http://wtr.rubyforge.org/">WATIR</a> it gives you a way to run an automated browser session against your app.

    For my money a much more productive use of your testing time than TDD.

  4. #4
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ianpurton View Post
    For my money a much more productive use of your testing time than TDD.
    No no no...both are important at different levels. Watir can be used to test your app at a higher, functional level (functional/acceptance testing) - it tests that your app does what it should, but it does *NOT* test your code (lower-level). Not only is TDD about testing your code (i.e. normal unit testing), it is a design methodology too. It helps you write simple, focussed code that does the least necessary to make the tests pass, it helps build up a good regression test suite and it gives confidence when refactoring.

    TDD isn't the be all and end all and doesn't work for everybody but unit testing is still very important regardless of whether you practice TDD - its just as important as functional tests.

  5. #5
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I used TDD for a while but it doesn't work for me. It's great to test non-trivial code using automated tests. (but most of my code is trivial though).
    Last edited by Fenrir2; Dec 19, 2006 at 14:20.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •