in reply to [Solved] Parameter injection for testing

Modulinos are too clever for me, i stick to modules Re: Modulino, perl -d question. ($0, __FILE__)
main(@ARGV) if $0 eq __FILE__;

Replies are listed 'Best First'.
Re^2: Parameter injection for testing
by Corion (Patriarch) on Aug 25, 2022 at 11:28 UTC

    This won't work if somebody invokes the module via a symlink or something like that...

Re^2: Parameter injection for testing
by davies (Monsignor) on Aug 25, 2022 at 13:37 UTC

    The point (for me) of using a modulino is that the code can be invoked from the command line, but it can be used by a test script and unit tests run. Have a look at Szabgab's post https://perlmaven.com/modulino-both-script-and-module. I have struggled with unit tests for command line scripts in the past & have found modulinos a very elegant solution.

    Regards,

    John Davies

      I'm using modulinos differently (at least I think so)

      If the module is called directly prove is executed.

      Like this I can hit F5 (run) in editor buffers holding the module for the whole suite or on individual test files for them only.

      Like with Perl::Tidy and perltidy.pl, I rather prefer one (or more) separate script.pl instead of adding that functionality into the module.

      And the scripts are also executed with the same F5 key.

      Some prefer an extra key/command to run the test suite but this requires individual configuration of the IDE or the "project file".

      I rather prefer holding the current prove config as perl code in the modules while developing.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery