Sawyer
Sawyer

Reputation: 15917

How to run a specific test plan

I am setting up my test environment to run tests on file changes, but I don't want to run all the test plans when test cases are changed.

How can I run a specific test plan in Perl? For example, I only want to run "test2"?

t/test.t

use Test::More;  
ok(1, "test1");

ok(1, "test2");
... 
done_testing();

Upvotes: 0

Views: 178

Answers (1)

marram
marram

Reputation: 439

If I were you I'd do the following:

1 - if you might want to separate some test from the others, put it in some other test suite...

t/00-always_runs.t
t/01-maybe_not_so_often.t

2 - if the test you're willing to skip depends on some feature or availability on some object, try using a skip block like in Test::More documentation

SKIP: {
    skip $why, $how_many unless $have_some_feature;

    ok( foo(),       $test_name );
    is( foo(42), 23, $test_name );
};

From https://metacpan.org/pod/Test::More

Hope it helps and gets you going! Good luck.

Upvotes: 1

Related Questions