James Counts > Test-Approvals-v0.0.4 > Test::Approvals

Download:
Test-Approvals-v0.0.4.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: v0.0.4   Source   Latest Release: Test-Approvals-v0.0.5

NAME ^

Test::Approvals - Capture human intelligence in your tests

VERSION ^

This documentation refers to Test::Approvals version v0.0.4

SYNOPSIS ^

    use Test::Approvals qw(use_reporter verify_ok);

    use_reporter('Test::Approvals::Reporters::DiffReporter');
    verify_ok 'Hello', 'Hello Test';

DESCRIPTION ^

The Test::Approvals modules provides the top level interface to ApprovalTestss for Perl. You can use ApprovalTests to verify objects that require more than a simple assert, including long strings, large arrays, and complex hash structures and objects. Perl already has great modules that overlap with ApprovalTests, but Test::Approvals really shines when you take advantage of reporters to provide different views into failing tests. Sometimes printing to STDOUT just isn't enough.

SUBROUTINES/METHODS ^

namer

    my $namer = namer();

Gets the currently configured Test::Approvals::Namers:: instance.

reporter

    my $reporter = reporter();

Gets the currently configured Test::Approvals::Reporters:: instance.

use_name

    my $namer = use_name('My Test Name');

Construct a namer for the specified name, configure it as the current instance, and return the instance.

use_reporter

    my $reporter = use_reporter('Test::Approvals::Reporters::DiffReporter');

Construct a reporter of the specified type, configure it as the current instance, and return the instance.

use_reporter_instance

    my $reporter = Test::Approvals::Reporters::DiffReporter->new();
    my $ref = use_reporter_instance($reporter);

Like 'use_reporter', but use the provided instance instead of constructing a new instance.

verify

    my $ok = verify('Hello');
    ok $ok, 'My Test';

Construct a writer for the specified data and use it (along with the current namer and reporter instances) to verify against the approved data. Returns a value indicating whether the data matched. The reporter is launched when appropriate.

You can pass anything to verify that Perl can easily stringify in a scalar context. So, passing an array, a hash, or raw reference to verify is not going to produce useful results. In these cases, take advantage of Data::Dumper.

    use Data::Dumper;
    my %person = ( First => 'Fred', Last => 'Flintrock' );
    ok verify(Dumper( \%person )), 'Fred test';

verify_ok

    use_name('Hello Test');
    verify_ok('Hello');

Like 'verify', but also automatically call 'ok' with the test name provided by the current namer instance. Or you can pass the name explicitly for a more traditional Test::More experience:

    verify_ok 'Hello', 'Hello Test';

DIAGNOSTICS ^

None at this time.

CONFIGURATION AND ENVIRONMENT ^

None.

DEPENDENCIES ^

Exporter Test::Builder version

INCOMPATIBILITIES ^

None known.

BUGS AND LIMITATIONS ^

Windows-only. Linux/OSX/other support will be added when time and access to those platforms permit.

AUTHOR ^

Jim Counts - @jamesrcounts

LICENSE AND COPYRIGHT ^

Copyright (C) 2013 Jim Counts

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    L<http://www.apache.org/licenses/LICENSE-2.0>

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

syntax highlighting: