Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/schwern/test-sims
Perl module to help build up complex, semi-random data for testing.
https://github.com/schwern/test-sims
Last synced: 3 months ago
JSON representation
Perl module to help build up complex, semi-random data for testing.
- Host: GitHub
- URL: https://github.com/schwern/test-sims
- Owner: schwern
- Created: 2009-06-28T04:53:19.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2019-05-10T16:04:54.000Z (over 5 years ago)
- Last Synced: 2024-10-03T12:38:36.966Z (3 months ago)
- Language: Perl
- Homepage: http://metacpan.org/release/Test-Sims
- Size: 34.2 KB
- Stars: 6
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
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:
http://schwern.org/talks/Generating%20Test%20Data%20With%20The%20Sims.pdfInstall as any normal Module::Build Perl module.
perl Build.PL
./Build
./Build test
sudo ./Build installOr for your own personal use:
perl Build.PL --install_base ~
./Build
./Build test
./Build installHere'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()
export_sims();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
);