mercredi 19 avril 2017

Running only one named test case in a Perl test file

I am trying to find if it is possible to run just one test case in a Perl test file. For example, consider the following Perl test file (copied from http://ift.tt/2pCM8Rg):

#!/usr/bin/perl

use strict;
use warnings;

use Test::Simple tests => 2;

sub hello_world
{
return "Hello world!";
}

sub get_number
{
return int(rand(1000));
}
ok( hello_world( ) eq "Hello world!", "My Testcase 1" );
ok( get_number( ) > 0, "My Testcase 2" );

When I run this file using command prove -v test.t I get following output:

test.t .. 
1..2
ok 1 - My Testcase 1
ok 2 - My Testcase 2
ok

Now, I just want to run the 2nd test case i.e. My Testcase2. Is there a way to execute just one named test case in a test file?

Aucun commentaire:

Enregistrer un commentaire