Domanda

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.

È stato utile?

Soluzione

Yes. Why wouldn't it be?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top