[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Unit test filename convention

mmalaidini

3/29/2008 11:20:00 PM

All,

I'm just starting with Netbeans 6.1 after having used Eclipse RDT for a
while. I was used to keep unit tests within the same file (delimited by
if $0 == __FILE__), but now I guess there's a shift towards separate
files.

Which is the current trend in the community for what is related to unit
tests filename? I've never bought into the TC_* style, it's ugly and
fairly disruptive. What about yada_test.rb for class Yada defined in
yada.rb?

Thanks
MM
--
Posted via http://www.ruby-....

4 Answers

Phlip

3/30/2008 1:29:00 AM

0

Manlio Malaidini wrote:

> What about yada_test.rb for class Yada defined in
> yada.rb?

Yes. Rails's unit test generators show the merits of that style.

Specificially, this folder...

test_ya.rb
test_yo.rb
test_yu.rb

is more editing-hostile than this:

ya_test.rb
yo_test.rb
yu_test.rb

The former is harder to access with editing commands that automatically
complete filenames. Under "tab completion" for Bash, for example, you must
type >5 letters before typing a distinct character.

For the second style, you type as few as 1 letters, and you can hit <Tab> to
complete the filename.

The next question is whether to snuggle the test suites in next to their
tested files.

ya.rb
ya_test.rb
yo.rb
yo_test.rb
...

Sometimes that has merit, but developers generally don't need a slavish
one-to-one correspondence between classes and suites. Tests are about
feature and behavior, not structure. Apps generally use /src and /test
folders to keep each folder short.

--
Phlip


Eric Hodel

3/30/2008 2:09:00 AM

0

On Mar 29, 2008, at 16:19 PM, Manlio Malaidini wrote:
> All,
>
> I'm just starting with Netbeans 6.1 after having used Eclipse RDT
> for a
> while. I was used to keep unit tests within the same file (delimited
> by
> if $0 == __FILE__), but now I guess there's a shift towards separate
> files.
>
> Which is the current trend in the community for what is related to
> unit
> tests filename? I've never bought into the TC_* style, it's ugly and
> fairly disruptive. What about yada_test.rb for class Yada defined in
> yada.rb?


lib/yada.rb # class/module Yada
test/test_yada.rb # class TestYada < Test::Unit::TestCase

(Which works out-of-the-box with autotest, but since you're using
Eclipse, you probably don't care.)

mmalaidini

3/30/2008 3:53:00 AM

0

Eric Hodel wrote:
> On Mar 29, 2008, at 16:19 PM, Manlio Malaidini wrote:
>> unit
>> tests filename? I've never bought into the TC_* style, it's ugly and
>> fairly disruptive. What about yada_test.rb for class Yada defined in
>> yada.rb?
>
>
> lib/yada.rb # class/module Yada
> test/test_yada.rb # class TestYada < Test::Unit::TestCase
>

It makes perfect sense, thank you.

> (Which works out-of-the-box with autotest, but since you're using
> Eclipse, you probably don't care.)

I've just switched to Netbeans. So far so good. Well, much better to be
honest.

Thanks
MM
--
Posted via http://www.ruby-....

mmalaidini

3/30/2008 8:54:00 PM

0

Something strange: I haven't seen your response in neither ruby-
talk.org or ruby-forum. I guess you posted from comp.lang.ruby.

So the question is: what's the status of the bridge?

Thanks
MM

On Mar 29, 9:28 pm, "Phlip" <phlip2...@gmail.com> wrote:
[...]