You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
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:
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.
Original: https://rt.cpan.org/Ticket/Display.html?id=100411
The text was updated successfully, but these errors were encountered: