Skip Menu |

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

Report information
The Basics
Id: 100411
Status: new
Priority: 0/
Queue: Test-Class

People
Owner: Nobody in particular
Requestors: dariusjokilehto [...] yahoo.co.uk
Cc:
AdminCc:

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



Subject: Test::Class modules in aggregate test run leak into subsequent run modules
Date: Mon, 17 Nov 2014 18:03:40 +0000 (UTC)
To: "bug-Test-Class [...] rt.cpan.org" <bug-Test-Class [...] rt.cpan.org>
From: Darius Jokilehto <dariusjokilehto [...] yahoo.co.uk>
In our test suite we have some Test::Class modules that all inherit from a subclass of Test::Class, and get run by a .t file that does the following: use Test::Class::Load "./t/classes"; Test::Class->runtests; We have recently been debugging some tests that create a mock object in their 'setup' method, and store it against $_[0]{mocked}, and it looks like this doesn't get destroyed once the test class module has finished running and moved onto the next module, which means our mocked objects leak into our next tests. I can't think of a case where this behaviour would be the desired one, I'd have thought the objects should get cleaned up once we've moved onto the next test class. Looking at the implementation, it seems the cause is this line in runtests: foreach my $t (@tests) { # stuff $t = $t->new unless ref($t); Since $t is an alias to an element of @tests, it won't be destroyed until the runtests method ends. You could just use a different variable to store the instance.