Hi Monks,

Here is what I have:

1. Example::Module1 with test cases - t001 t002
2. Example::Module2 with test cases - t001 t002 t003


Here is what I want to achieve:
1. Run ONLY t001 from Example::Module1
2. Run ONLY t002 from Example::Module2

if I use:
use Example::Module1
Test::Class-> runtests;
it will run all all tests in Module 1 viz. t001 and t002 in our case.

Test::Class allows you to run individual tests using $ENV{TEST_METHOD} variable.

I'm trying to run individual test cases using this as the .t file:
use Example::Module1; $ENV{TEST_METHOD} = '.*t001.*'; Test::Class->runtests; use Example::Module2; $ENV{TEST_METHOD} = '.*t002.*'; Test::Class->runtests;
The problem with the above code is that it runs t001 from Module1 correctly but it runs t001 AND t002 both from Module2. I just want it to run t002 from module2. I don't know why it is running the t001 from Module2, seems it's persisting with the first pattern match with the second module as well.

How do I correctly run this?

In reply to Running specific test cases with Test::Class by mkhan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.