2

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.

Zaid
  • 36,680
  • 16
  • 86
  • 155

1 Answers1

2

Yes. Why wouldn't it be?

ikegami
  • 367,544
  • 15
  • 269
  • 518
  • 1
    "Each `SKIP` block must have the label `SKIP`, or `Test::More` can't work its magic." The concern was that the magic would spill over to the `ok()` (It's inside the block) – Zaid Feb 03 '13 at 17:40
  • 1
    `skip` does `last SKIP;`. `ok` doesn't. – ikegami Feb 03 '13 at 17:53