As promised - my example:

package Class::EmployeeTest;

use strict;
use vars qw(@ISA);

use base qw(Test::Unit::TestCase);

sub new {
        my $self = shift()->SUPER::new(@_);
        $self->{'_name'}       = '';
        $self->{'_department'} = '';

        return $self;
}

sub set_up {
        my $self = shift;

        $self->{'_name'}       = 'Arne Raket';
        $self->{'_department'} = 'dA pErl lAb';
}

sub test_name {
        my $self = shift;

        my $name = $self->{_name};
        $self->assert($name eq 'Arne Raket');
}

sub test_department {
        my $self = shift;
        my $department = $self->{'_department'};
        $self->assert($department eq 'dA pErl lAb');
}

1;

The name (_name) field clashes, I guess that name is probably the most used
field in OOP. It should therefore not be used in Test::Unit::TestCase.

I have made a brief workaround (see the attached patch).

Changing the internal field to Test::Unit::TestCase::_name_of_test is not a
valid solution though :-/

So a proper namespace protection scheme should be implemented. I have tried to
fool around with this (using Tie::Securehash) without any luck, since the
Assert.pm tries to access the _no_backtrace_on_fail at runtime.

Either the component structure should be change or a different scheme should be chosen.

jonasbn
-- 
Eml: [EMAIL PROTECTED] || ICQ: 62401545
WWW: http://jonasbn.hjem.wanadoo.dk/

--- /home/jonasbn/TestCase.pm   Thu Feb 21 19:58:40 2002
+++ TestCase.pm Wed Mar  7 21:15:14 2001
@@ -13,7 +13,7 @@
 sub new {
     my $class = shift;
     my ($name) = @_;
-    bless { _name_of_test => $name }, $class;
+    bless { _name => $name }, $class;
 }
 
 sub count_test_cases {
@@ -28,7 +28,7 @@
 
 sub name {
     my $self = shift;
-    return $self->{_name_of_test};
+    return $self->{_name};
 }

Reply via email to