~ubuntu-branches/ubuntu/trusty/libfennec-perl/trusty-proposed

« back to all changes in this revision

Viewing changes to README

  • Committer: Package Import Robot
  • Author(s): Xavier Guimard
  • Date: 2013-06-21 06:29:36 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130621062936-lr1472qi38e2nw7b
Tags: 2.009-1
* Imported Upstream version 2.009
* Update spelling errors patch
* Add version to libmock-quick-perl dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
260
260
        Load these modules that have reusable tests. Reusable tests are
261
261
        tests that are common to multiple test files.
262
262
 
 
263
    seed => '...'
 
264
        Set the random seed to be used. Defaults to current date, can be
 
265
        overriden by the FENNEC_SEED environment variable.
 
266
 
 
267
    debug => $BOOL
 
268
        Can be used to turn on internal debugging for Fennec. This currently
 
269
        does very little.
 
270
 
 
271
ENVIRONMENT VARIABLES
 
272
    FENNEC_SEED
 
273
        Can be used to set a specific random seed
 
274
 
 
275
    FENNEC_TEST
 
276
        Can be used to tell Fennec to only run specific tests (can be given
 
277
        a line number or a block name).
 
278
 
 
279
    FENNEC_DEBUG
 
280
        When true internal debugging is turned on.
 
281
 
263
282
EXPORTED FUNCTIONS
264
283
  FROM FENNEC
265
284
    done_testing()
500
519
 
501
520
        # use qstrict() to make an object that does not autovivify accessors.
502
521
 
 
522
   SCOPE OF MOCKS IN FENNEC
 
523
    With vanilla Mock::Quick a mock is destroyed when the control object is
 
524
    destroyed.
 
525
 
 
526
        my $control = qtakeover Foo => (blah => 'blah');
 
527
        is( Foo->blah, 'blah', "got mock" );
 
528
        $control = undef;
 
529
        ok( !Foo->can('blah'), "Mock destroyed" );
 
530
 
 
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" );
 
535
 
 
536
    With the workflow support provided by Fennec, you can omit the control
 
537
    object and let the mock be scoped implicitly.
 
538
 
 
539
        tests implicit_mock_scope => sub {
 
540
            my $self = shift;
 
541
            can_ok( $self, 'QINTERCEPT' );
 
542
            qtakeover Foo => (blah => sub { 'blah' });
 
543
            is( Foo->blah, 'blah', "Mock not auto-destroyed" );
 
544
        };
 
545
 
 
546
        describe detailed_implicit_mock_scope => sub {
 
547
            qtakeover Foo => ( outer => 'outer' );
 
548
            ok( !Foo->can( 'outer' ), "No Leak" );
 
549
 
 
550
            before_all ba => sub {
 
551
                qtakeover Foo => ( ba => 'ba' );
 
552
                can_ok( 'Foo', qw/outer ba/ );
 
553
            };
 
554
 
 
555
            before_each be => sub {
 
556
                qtakeover Foo => ( be => 'be' );
 
557
                can_ok( 'Foo', qw/outer ba be/ );
 
558
            };
 
559
 
 
560
            tests the_check => sub {
 
561
                qtakeover Foo => ( inner => 'inner' );
 
562
 
 
563
                can_ok( 'Foo', qw/outer ba be inner/ );
 
564
            };
 
565
 
 
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" );
 
570
        };
 
571
 
503
572
   TAKEOVER AN EXISTING CLASS
504
573
        require Some::Class;
505
574
        my $control = qtakeover 'Some::Class' => (