http://www.perlmonks.org?node_id=316466


in reply to Re: Thoughts on making modules
in thread Thoughts on making modules

I have a tool for that, too. It's ~/bin/newtest:

#!/usr/bin/perl -w use strict; use File::Path; use File::Basename; my $progfile = basename( $0 ); die "$progfile <modname> <test filename>\n" unless @ARGV >= 2; my ($modname, $filename) = @ARGV; my $filepath = dirname( $filename ); mkpath( $filepath ) unless -e $filepath; open my $out, '>', $filename or die "Can't open '$filename': $!"; print $out <<END_HERE; #!/usr/bin/perl -w BEGIN { chdir 't' if -d 't'; use lib '../lib', '../blib/lib'; } use strict; use Test::More 'no_plan'; # tests => 1; my \$module = '$modname'; use_ok( \$module ) or exit; END_HERE

For Some::Module, run newtest Some::Module t/testfile.t.

Replies are listed 'Best First'.
Re: Automating Writing Regression Tests
by Juerd (Abbot) on Dec 22, 2003 at 20:12 UTC

    Hm, that's kind of what h2xs also generates. But I was talking about the actual unit tests, more than just use_ok. Wouldn't it be great if with one simple command, something would analyze a requirements list and translate it to tests? But if that were possible, we could also make it write the code itself, and we'd be out of a job.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      I started something to this end here. I might actually pick this script up again and iron it out some more.
      -brad..