The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Test::UniqueTestNames - Make sure all of your tests have unique names

VERSION

Version 0.04

SYNOPSIS

For scripts that have no plan:

  use Test::UniqueTestNames;

that's it, you don't need to do anything else.

For scripts that have a plan, like this:

  use Test::More tests => x;

change to

  use Test::More tests => x + 1;
  use Test::UniqueTestNames;

DESCRIPTION

Test names are useful in assessing the contents of a test file. They're also useful in debugging. And when a test breaks, it's much easier to figure out what test broke if the test names are unique. This module checks the names of every test to make sure that they're all unique. If there are any tests that have duplicate names, it wil give a "not ok" and diagnostics of which test names have been used for multiple tests.

Test names aren't required by most testing modules, but by default Test::UniqueTestNames counts tests without names as failures. You can change that behavior by importing unnamed_ok.

Specifically, this module is useful in the situation where tests are run in a loop, such as these:

  for( @fixture_data ) {
    my( $input, $output ) = @$_;

    ok( Some::Class->method( $input ), "...and the method works"; # test name will be the same each time

    is( Some::Class->method( $input ), $output, "...and the method works with $input"; # names could be the same
                                                                                       # if there is a duplicate in $input
  }

This test is similar in most respects to Test::NoWarnings.

CAVEATS

Some tests generate their own test names, and thus shouldn't be counted as failures when they have non-unique test names. This currently only applies to Test::More's isa_ok.

EXPORTED FUNCTIONS

had_unique_test_names()

This checks to see that all tests had unique names. Usually you will not call this explicitly as it is called automatically when your script finishes.

AUTHOR

Josh Heumann, <cpan at joshheumann.com>

BUGS

Using with Test::Exception

This module currently throws a warning when used with Test::Exception. This is due to a bug in Hook::LexWrap, and a patch has been submitted to correct the problem.

Please report any bugs or feature requests to bug-test-uniquetestnames at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-UniqueTestNames. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SEE ALSO

Test::NoWarnings

COPYRIGHT & LICENSE

Copyright 2008 Josh Heumann, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.