Talk:Test::Unit

From Perl QA

Jump to: navigation, search

Why should Test::Unit::TestCase's do the sub new { shift()->SUPER::new(@_); } incantation? So far, I haven't been able to observe a difference between the behavior of when that exists versus when it doesn't.

For the same reason any other well behaved subclass would, to inherit any behaviors its parent might do, in this case object initialization. Just because it doesn't do anything now doesn't mean it won't later. --Schwern 19:11, 10 July 2006 (PDT)


Test::Unit corresponds most to JUnit 2/3. Is it going to be revised to more closely match the new structure of JUnit 4.x (annotations, no longer have to extend TestCase, etc.)--Adrianh 08:32, 16 July 2006 (PDT)

This is something you should really ask the author as he probably doesn't read this Wiki. --Schwern 14:01, 16 July 2006 (PDT)

---

I suspect that you'll find the shift->SUPER::new(@_) incantation mandatory if it's a straight port of Java code because in Java, you don't have sub new {}, you have constructors named after the class and the super class constructor is automatically called. Further, it is called before any other code in a constructor is called (otherwise the your program won't even compile). Thus, Java programmers using Test::Unit will expect similar behavior and shift->SUPER::new(@_) supplies that, assuming it's the first line of the constructor. --Ovid 17:10, 18 July 2006 (GMT)

Personal tools
Mongers