Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Perl module to help build up complex, semi-random data for testing.

branch: master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 inc
Octocat-spinner-32 lib
Octocat-spinner-32 t
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .perlcriticrc
Octocat-spinner-32 .perltidyrc
Octocat-spinner-32 Build.PL
Octocat-spinner-32 Changes
Octocat-spinner-32 MANIFEST
Octocat-spinner-32 MANIFEST.SKIP
Octocat-spinner-32 META.yml
Octocat-spinner-32 README
Test::Sims is a Perl module to support the Sims testing technique to generate
large, complex, interesting, semi-random yet valid data for testing purposes.

Here's the slides outlining the technique:

Install as any normal Module::Build Perl module.

    perl Build.PL
    ./Build test
    sudo ./Build install

Or for your own personal use:

    perl Build.PL --install_base ~
    ./Build test
    ./Build install

Here's an example of making a simple package to generate random dates.

    package Sim::Date;

    use strict;
    use warnings;

    use DateTime;
    use Test::Sims;

    # Create rand_year(), rand_month(), etc...
    # All exportable on demand or with the :rand tag
    make_rand year  => [1800..2100];
    make_rand month => [1..12];
    make_rand day   => [1..31];
    make_rand hour  => [0..23];
    make_rand minute=> [0..59];
    make_rand second=> [0..59];

    sub sim_datetime {
        my %defaults = (
            year   => rand_year(),
            month  => rand_month(),
            day    => rand_day(),
            hour   => rand_hour(),
            minute => rand_minute(),
            second => rand_second(),

        return DateTime->new(
            %defaults, @_

    # Export sim_datetime()

And then using it.

    use Sim::Date;

    # Random date.
    my $date = sim_datetime;

    # Random date in the year 2009
    my $date = sim_datetime(
        year => 2009
Something went wrong with that request. Please try again.