Testing a standalone script

2013-10-29 Thread Manfred Lotz
Hi there,
I have some relatively small standalone perl scripts where I would like
to include tests.

Which is the recommended way to test standalone scripts?


-- 
Manfred

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Testing a standalone script

2013-10-29 Thread Shawn H Corey
On Tue, 29 Oct 2013 17:10:51 +0100
Manfred Lotz manfred.l...@arcor.de wrote:

 Hi there,
 I have some relatively small standalone perl scripts where I would
 like to include tests.
 
 Which is the recommended way to test standalone scripts?
 
 

Put the tests in a directory call t under the source. And see
`man prove`. `prove` is a Perl tool for testing modules but it can be
adapted for scripts. Each test script is given the extension *.t .


-- 
Don't stop where the ink does.
Shawn

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Testing a standalone script

2013-10-29 Thread Manfred Lotz
On Tue, 29 Oct 2013 12:36:58 -0400
Shawn H Corey shawnhco...@gmail.com wrote:

 On Tue, 29 Oct 2013 17:10:51 +0100
 Manfred Lotz manfred.l...@arcor.de wrote:
 
  Hi there,
  I have some relatively small standalone perl scripts where I would
  like to include tests.
  
  Which is the recommended way to test standalone scripts?
  
  
 
 Put the tests in a directory call t under the source. And see
 `man prove`. `prove` is a Perl tool for testing modules but it can be
 adapted for scripts. Each test script is given the extension *.t .
 
 

This is exactly what I don't want to do. IMHO, for testing modules or
applications this is the way to go. However, for a standalone script
I'd like to have my test data inside the script itself.

-- 
Manfred



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Testing a standalone script

2013-10-29 Thread John SJ Anderson
On Tue, Oct 29, 2013 at 11:02 AM, Manfred Lotz manfred.l...@arcor.de wrote:
 This is exactly what I don't want to do. IMHO, for testing modules or
 applications this is the way to go. However, for a standalone script
 I'd like to have my test data inside the script itself.

Well, you could add some input values and expected results in a
__DATA__ section (maybe as some sort of YAML or other serialization
format), and then add a '-T' runtime option that reads that data in,
runs it through the program, and uses 'require' to load Test::More to
get access to functions like is() and ok() and friends, and use those
to compare your inputs to your expected results.

Is something like that what you're envisioning?

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Testing a standalone script

2013-10-29 Thread Manfred Lotz
On Tue, 29 Oct 2013 12:01:52 -0700
John SJ Anderson geneh...@genehack.org wrote:

 On Tue, Oct 29, 2013 at 11:02 AM, Manfred Lotz
 manfred.l...@arcor.de wrote:
  This is exactly what I don't want to do. IMHO, for testing modules
  or applications this is the way to go. However, for a standalone
  script I'd like to have my test data inside the script itself.
 
 Well, you could add some input values and expected results in a
 __DATA__ section (maybe as some sort of YAML or other serialization
 format), and then add a '-T' runtime option that reads that data in,
 runs it through the program, and uses 'require' to load Test::More to
 get access to functions like is() and ok() and friends, and use those
 to compare your inputs to your expected results.
 
 Is something like that what you're envisioning?
 

This comes close. 

In the meantime I found that there are even packages like
Test::Standalone or Test::Inline supporting what I want. Does anybody
know those packages and is able to recommend one?

-- 
Manfred




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/