Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Unit Testing Without Frameworks

Reply
Thread Tools

Unit Testing Without Frameworks

 
 
Sean O'Dell
Guest
Posts: n/a
 
      07-06-2004
On Tuesday 06 July 2004 13:55, Lothar Scholz wrote:
>
> And to be honest i stopped unit tests, because the current libraries
> GUI, networking, filesystems do not support them well enough. Hope
> that this will improve in the future.


I felt the same way. I got back into unit testing in a way I don't think most
people would understand. I dropped frameworks altogether. I started just
running anything found in a "tests" sub-directory of whatever project I was
working on.

Actually, I do have a framework of a sort: a single ruby file I use to launch
tests that match a given name pattern. Here's the entire "framework":

#!/usr/bin/ruby

pattern = nil
pattern = Regexp.new(ARGV.shift) if (ARGV.length > 0)

Dir["tests/*"].each do | filename |
next if (filename =~ /^\./)

test = filename.clone
test.slice!(/^.+\//)
test.slice!(/\.rb$/)

next if (not test =~ /^test_/)
test.slice!(/^test_/)

next if (pattern and not test =~ Regexp.new("^#{pattern}$"))

print("---------- #{test}' ----------\n")
system(filename)
end

print("---------- DONE ----------\n")



Generally, in my tests, I just do whatever and let exceptions happen where
they happen, and every test usually ends with a statement like:

p a == expected_value

So my entire "report" consists of a series of true or falses. When a false
occurs, I just track it down and fix whatever caused the bug.

Perhaps it's just my need for simplicity that makes this work better for me
than a framework. Or perhaps current frameworks don't have the ability to
really anticipate what everyone needs or wants. Whatever the reason, I am
really into unit testing now.

Sean O'Dell


 
Reply With Quote
 
 
 
 
Randy Lawrence
Guest
Posts: n/a
 
      07-11-2004
Sean O'Dell wrote:
> On Tuesday 06 July 2004 13:55, Lothar Scholz wrote:
>
>>And to be honest i stopped unit tests, because the current libraries
>>GUI, networking, filesystems do not support them well enough. Hope
>>that this will improve in the future.

>
>
> I felt the same way. I got back into unit testing in a way I don't think most
> people would understand. I dropped frameworks altogether. I started just
> running anything found in a "tests" sub-directory of whatever project I was
> working on.
>
> Actually, I do have a framework of a sort: a single ruby file I use to launch
> tests that match a given name pattern. Here's the entire "framework":
>
> #!/usr/bin/ruby
>
> pattern = nil
> pattern = Regexp.new(ARGV.shift) if (ARGV.length > 0)
>
> Dir["tests/*"].each do | filename |
> next if (filename =~ /^\./)
>
> test = filename.clone
> test.slice!(/^.+\//)
> test.slice!(/\.rb$/)
>
> next if (not test =~ /^test_/)
> test.slice!(/^test_/)
>
> next if (pattern and not test =~ Regexp.new("^#{pattern}$"))
>
> print("---------- #{test}' ----------\n")
> system(filename)
> end
>
> print("---------- DONE ----------\n")
>
>
>
> Generally, in my tests, I just do whatever and let exceptions happen where
> they happen, and every test usually ends with a statement like:
>
> p a == expected_value
>
> So my entire "report" consists of a series of true or falses. When a false
> occurs, I just track it down and fix whatever caused the bug.
>
> Perhaps it's just my need for simplicity that makes this work better for me
> than a framework. Or perhaps current frameworks don't have the ability to
> really anticipate what everyone needs or wants. Whatever the reason, I am
> really into unit testing now.
>
> Sean O'Dell
>
>


I used to feel the same until I came across this page. It's the best 10
minutes I've ever invested on the topic of unit testing.

http://www.rubygarden.org/ruby?UsingTestUnit

I evaluated but did not use unit-testing frameworks in Java and C++
because they seemed like too much hassle.

The above page describes a scenario using Test::Unit that is so simple,
I bet it's even easier than many homegrown testing methods.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
unit-profiling, similar to unit-testing Ulrich Eckhardt Python 6 11-18-2011 02:00 AM
Unit testing errors (testing the platform module) John Maclean Python 1 04-13-2010 02:11 PM
Test::Unit - Ruby Unit Testing Framework Questions Bill Mosteller Ruby 0 10-22-2009 02:02 PM
Unit testing frameworks grkuntzmd@gmail.com Python 7 03-29-2009 08:17 PM
Unit testing GUI, possible frameworks Phillip Lord Java 0 03-02-2004 12:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57