Skip Menu |

This queue is for tickets about the Test-Class CPAN distribution.

Report information
The Basics
Id: 31270
Status: rejected
Priority: 0/
Queue: Test-Class

People
Owner: Nobody in particular
Requestors: agianni [...] buffalo.edu
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Allow for test method names that would otherwise collide with core method names
I like to write my test classes in parallel with the actual classes I'm testing. This usually includes method names, which makes it easy for me to see what I'm testing. The only problem I've run into, is that if one of my methods is the same as the name of a core method of Test::Class, I have a problem because my test overrides the Test::Class functionality. The most obvious example of this occurs in writing a test for my new method. If I declare: sub new : Test( 5 ){ # blah blah blah } my test ain't gonna work. This isn't really a big deal, and I know now to name my new tests test_new, but it hung me up for a while and I'm sure I'm not the only one. I know this would likely require some Perl Black Magic and can't be prioritized that high, but it sure would be nice. Actually, I'd be happy to talk with you about implementation strategies and try to write the patch myself. I have a couple of ideas, but nothing concrete. Let me know what you think.
Hiya, On Thu Dec 06 09:36:08 2007, agianni@buffalo.edu wrote: Show quoted text
> I like to write my test classes in parallel with the actual classes I'm > testing. This usually includes method names, which makes it easy for me > to see what I'm testing. The only problem I've run into, is that if one > of my methods is the same as the name of a core method of Test::Class, I > have a problem because my test overrides the Test::Class functionality. > The most obvious example of this occurs in writing a test for my new > method. If I declare: > > sub new : Test( 5 ){ > # blah blah blah > } > > my test ain't gonna work. This isn't really a big deal, and I know now > to name my new tests test_new, but it hung me up for a while and I'm > sure I'm not the only one. I know this would likely require some Perl > Black Magic and can't be prioritized that high, but it sure would be nice. > > Actually, I'd be happy to talk with you about implementation strategies > and try to write the patch myself. I have a couple of ideas, but nothing > concrete. > > Let me know what you think.
I'm afraid I'm going to need some convincing on this one :-) T::C was very deliberately designed to be a "normal" perl class, capable of being sub-classed, etc. Having sub-classing do odd magic things goes against that (and will also break folk who are already sub-classing and overriding new() deliberately). The simpler solution of picking a test method name that more closely matches the behaviour being tested seems a better one to me. Sorry! Cheers, Adrian