Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Testing scripts under Test::More (with Test::Script)

by bliako (Monsignor)
on Jun 02, 2023 at 11:40 UTC ( #11152604=perlquestion: print w/replies, xml ) Need Help??

bliako has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I need to test a perl script which offers CLI functionality for some module.

I have discovered Test::Script and its script_fails() which is great.

BUT, I have noticed that in its synopsis it uses Test2::V0 as its general testing framework, And internally it depends on Test2::API. Unfortunately, I started this module some time ago and used Test::More. And I would not be happy changing horses mid-stream, as they say.

My questions are:

  1. Is there an alternative to script_fails() but without a Test2 (or any other Test[0-9]+ except Test::More) dependency?
  2. Is Test2 compatible with Test::More (can I just replace use Test::More and get on with it?)
  3. Test::Script's synopsis starts with:

    use Test2::V0; use Test::Script;

    I guess I have to start my tests in the same way and declare a dependency on Test2::V0 as well?

many thanks,

bw, bliako

Replies are listed 'Best First'.
Re: Testing scripts under Test::More (with Test::Script)
by hippo (Bishop) on Jun 02, 2023 at 12:17 UTC

    My understanding is that Test::Script will happily work in a dist which uses Test::More for all its other tests. They should be able to co-exist quite happily (one advantage of TAP being extremely simple). So you can keep your existing tests, use Test::Script just for the scripts and not worry about it.


      thank you for the insight. Goodbyte!

Re: Testing scripts under Test::More (with Test::Script)
by Haarg (Priest) on Jun 02, 2023 at 13:52 UTC
    Test::More uses the same back end as Test2::V0. You can use Test::Script with either one without any issue.

      yep, thanks for your helpful comment. It clears my doubts.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11152604]
Approved by marto
Front-paged by Bod
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2023-12-10 16:17 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (40 votes). Check out past polls.