What language community has a greater reputation for being obsessed with TDD?
— Obie: NO, Giles Bowkett (discussing Ruby)
Perl has had a canonical test suite in the core repository and shipped those tests with every source distribution since 1987. As of at least Ruby 1.8.7 (May 2008), this was not true of Ruby.
The third edition of Programming Perl, released in 2000, had a short (less than a page) discussion of Perl's testing modules and the CPAN testing system. The first edition of Programming Ruby, released in 2001, has no mention of testing that I can find.
Test::Builder, written in 2002, allows the existence of hundreds of Perl testing modules which can all work together in the same program to improve testing and the reusability, abstraction, and clarity of test programs. To my knowledge, Ruby has nothing like this.
The CPAN Testers project is nearly 11 years old (May 1998). Every distribution uploaded to the CPAN receives test reports for myriad combinations of operating system and version. The Perl CPAN culture encourages a testing culture, and has done so since before anyone in the US had even heard of Ruby. (Ruby has nothing quite like the CPAN.)
The Perl 6 specification includes a comprehensive test suite; every implementation of Perl 6 must pass this test suite to earn the label of "A conforming Perl 6 implementation". While the Rubinius project has done great work trying to create something similar for Ruby -- and while projects such as JRuby and IronRuby use this suite -- I'm not aware that the MRI developers have the same degree of interest in a comprehensive test suite.
This, then, is one of my persistent gripes with certain vocal members of the Ruby community. While it may be technically correct (the best kind of correct) that the Ruby community has the greatest reputation for testing of any other language community, the facts as I see them seem to contradict such a strong assertion.
Perl has had a canonical test suite in the core repository and shipped those tests with every source distribution since 1987. As of at least Ruby 1.8.7 (May 2008), this was not true of Ruby.
I wouldn't equate a core development team with that language's community. The Perl core team certainly was and is fanatical about testing, but the community? I think they caught up much later. In the case of Ruby we have the opposite situation - the community is good about testing, but the core team is not.
IMHO most language communities these days are pretty good about testing. At least I hope they are.
Test::Builder, written in 2002, allows the existence of hundreds of Perl testing modules which can all work together in the same program to improve testing and the reusability, abstraction, and clarity of test programs. To my knowledge, Ruby has nothing like this.
We've got Test::Unit (please use 2.x) and RSpec, with variations for each, and those seem to be enough. Adding features is usually a simple matter of subclassing (with Test::Unit anyway - I don't use RSpec). You'll have to be more specific about what you think we're missing.
Re:Red Apples vs Green Apples
chromatic on 2009-02-17T00:12:07
The Perl core team certainly was and is fanatical about testing, but the community? I think they caught up much later.
In 2000, CPAN authors had the expectation to write tests. The CPAN client ran those tests when installing modules.
It's 2009. Does Ruby gems run tests yet?
Adding features is usually a simple matter of subclassing (with Test::Unit anyway - I don't use RSpec).
You don't even have to do this with Perl. Someone writes a new test module, once, uploads it to the CPAN, and then everyone can use it without subclassing or trying to get multiple subclasses to work together nicely.
I haven't used RSpec, but the last time I tried to do anything useful with Test::Unit (2006), I very nearly ported Perl's Test::Builder and Test::More to Ruby so I wouldn't have to feel like a caveman trying to build a skyscraper out of bear skins and flint knives.
You'll have to be more specific about what you think we're missing.
A sense of proportion, a sober understanding of the rest of the world of programming, and a solid grasp of history would do nicely.
Re:Red Apples vs Green Apples
djberg96 on 2009-02-17T00:44:22
In 2000, CPAN authors had the expectation to write tests. The CPAN client ran those tests when installing modules.
Yeah, but I don't know when a real jump was made from running that stock one-test default test file that h2xs generated to people being really good about writing tests. That's hard to know for sure, but I would put it somewhere around 2002. But still, yeah, pretty good.
You don't even have to do this with Perl. Someone writes a new test module, once, uploads it to the CPAN, and then everyone can use it without subclassing or trying to get multiple subclasses to work together nicely.
Actually, I misspoke. With open classes you don't need to subclass, so just require'ing the library is good enough. That's what the context, matchy and stump libraries all do as far as I know.
It's 2009. Does Ruby gems run tests yet?
It's always been possible to my knowledge, it just doesn't run them by default. I think the decision to not run them by default is, in part, because of the weakness of Test::Unit 1.x.
Re:Red Apples vs Green Apples
chromatic on 2009-02-17T00:56:22
That's hard to know for sure, but I would put it somewhere around 2002.
It started in late 2001, but you're probably right that it only became popular and inevitable in 2002. I spent a lot of time in late 2001 avoiding finishing a book and writing tests for the Perl 5 core instead.
I think the decision to not run them by default is, in part, because of the weakness of Test::Unit 1.x.
That's what I don't get about the "Rah rah, TDD whee!" cheerleading from some parts of the Ruby community. You might as well not write tests if you're not going to run them.
Re:Red Apples vs Green Apples
Arador on 2009-02-17T01:30:46
That's what I don't get about the "Rah rah, TDD whee!" cheerleading from some parts of the Ruby community. You might as well not write tests if you're not going to run them.
Yeah, that makes no sense to me either.
Re:Red Apples vs Green Apples
Aristotle on 2009-02-17T01:51:45
IMHO most language communities these days are pretty good about testing.
How good? 200,000 fully automated test reports per month good?
Perl's name is mud to most people outside the community (or so it seems), but in my experience, the Java community has a very strong reputation for TDD. It's probably partly because Java is still the defacto language for a lot of new development, and a lot of new stuff tends to focus on modern practices.
But I do think the testing movement in Perl pre-dates even Java's. One reason why Perl doesn't use xUnit - it wasn't invented when the original test modules were written.
We all have biases towards our language of choice, mainly because we have more contact with that community than any other. It's usually a good idea to at least be aware of that bias.
I love Perl. I love testing
That said... while I see a lot of focus on *testing* in Perl. I've not encountered *that* much focus on TDD. They are - as you know - completely different things.
Now I've not spent huge amount of time with Ruby teams / code bases / community - so I can't say whether they're better or worse. But evidence of testing != evidence of TDD.
Re:TDD != testing
chromatic on 2009-02-17T18:03:13
TDD is all well and good, but if you don't run your tests, you've wasted your time writing them.
Say what you like about the Perl community, the language, our testing libraries, our culture, or whatever -- but we run our tests.
Re:TDD != testing
Adrian on 2009-02-18T07:57:34
TDD is all well and good, but if you don't run your tests, you've wasted your time writing them.
No I haven't. I still get the "D" from TDD. I get that even if a third party never runs my tests again.
I'm not saying running tests is useless. They're not. I'm not saying that the Perl/CPAN testing infrastructure isn't grand. It's fantastic - the best in any language that I've used.
I'm just saying that it has nothing to do with whether Perl folk do TDD. Because it doesn't. And that was the quote you seemed to be responding to. And because folk misunderstanding and misinterpreting what TDD is often causes me a major PITA for me - I niggle
:-) Whether the Ruby community is more obsessed with TDD than the Perl one - who knows...
(As an aside, and in my experience, the Perl/CPAN infrastructure supports testing really well doesn't seem to have any relation to whether teams writing Perl code in the wild do good testing - TDD or not. That, like most development issues, is down to good people. No matter what language they use.)
Re:TDD != testing
chromatic on 2009-02-18T08:40:08
As an aside, and in my experience, the Perl/CPAN infrastructure supports testing really well doesn't seem to have any relation to whether teams writing Perl code in the wild do good testing - TDD or not.
Agreed, but we can measure that neither for Perl nor Ruby.
Along those lines, I'm sure you have the same experience that I do, that many (if not most) people who claim to do TDD really don't, not in any pervasive fashion.
Perhaps I've overspoken here, especially claiming that TDD without running the tests is useless, but Giles implied that Ruby's superior obsession with TDD has some connection to quality. From what I can measure, I don't believe that Ruby's quality or testing practices are so superior to those of other languages.