260
260
Load these modules that have reusable tests. Reusable tests are
261
261
tests that are common to multiple test files.
264
Set the random seed to be used. Defaults to current date, can be
265
overriden by the FENNEC_SEED environment variable.
268
Can be used to turn on internal debugging for Fennec. This currently
271
ENVIRONMENT VARIABLES
273
Can be used to set a specific random seed
276
Can be used to tell Fennec to only run specific tests (can be given
277
a line number or a block name).
280
When true internal debugging is turned on.
263
282
EXPORTED FUNCTIONS
501
520
# use qstrict() to make an object that does not autovivify accessors.
522
SCOPE OF MOCKS IN FENNEC
523
With vanilla Mock::Quick a mock is destroyed when the control object is
526
my $control = qtakeover Foo => (blah => 'blah');
527
is( Foo->blah, 'blah', "got mock" );
529
ok( !Foo->can('blah'), "Mock destroyed" );
531
# WITHOUT FENNEC This issues a warning, the $control object is ignored so
532
# the mock is destroyed before it can be used.
533
qtakover Foo => (blah => 'blah');
534
ok( !Foo->can('blah'), "Mock destroyed before it could be used" );
536
With the workflow support provided by Fennec, you can omit the control
537
object and let the mock be scoped implicitly.
539
tests implicit_mock_scope => sub {
541
can_ok( $self, 'QINTERCEPT' );
542
qtakeover Foo => (blah => sub { 'blah' });
543
is( Foo->blah, 'blah', "Mock not auto-destroyed" );
546
describe detailed_implicit_mock_scope => sub {
547
qtakeover Foo => ( outer => 'outer' );
548
ok( !Foo->can( 'outer' ), "No Leak" );
550
before_all ba => sub {
551
qtakeover Foo => ( ba => 'ba' );
552
can_ok( 'Foo', qw/outer ba/ );
555
before_each be => sub {
556
qtakeover Foo => ( be => 'be' );
557
can_ok( 'Foo', qw/outer ba be/ );
560
tests the_check => sub {
561
qtakeover Foo => ( inner => 'inner' );
563
can_ok( 'Foo', qw/outer ba be inner/ );
566
ok( !Foo->can( 'outer' ), "No Leak" );
567
ok( !Foo->can( 'ba' ), "No Leak" );
568
ok( !Foo->can( 'be' ), "No Leak" );
569
ok( !Foo->can( 'inner' ), "No Leak" );
503
572
TAKEOVER AN EXISTING CLASS
504
573
require Some::Class;
505
574
my $control = qtakeover 'Some::Class' => (