Question

I've gone through the documentation and can't find a definitive answer to my query.

In a lot of my tests, the execution of a SKIP block is conditional to the success of a prior test.

So, for example, this what I write:

ok( @results > $threshold , 'Threshold met' );

SKIP: {
        skip 'due to insufficient results', 3
          unless @results > $threshold;
        # ...
}

If my test changes, I don't want to have to change two locations, so I'd like a DRY-er equivalent:

SKIP: {
        skip 'due to insufficient results', 3
          unless ok( @results > $threshold , 'Threshold met' );
        # ...
}

My initial tests suggest that the two snippets are equivalent.

However, something in the documentation caught my eye:

Each SKIP block must have the label SKIP, or Test::More can't work its magic.

My concern here is that the magic may spill over to the ok() as it is now inside the block.

Was it helpful?

Solution

Yes. Why wouldn't it be?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top