Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Makes the right use of T::Builder

- SKIP label seems unecessary
- If skip, we should exit from the loop to avoid *also* printing a 'not ok'
- Don't print last diag over and over again if we are skipping to the
  end, one is enough
- Tries to add a unit test for that, but I miserably failed
  • Loading branch information...
commit e489a48a1539e0af1612d475eeb4ca92345c25ed 1 parent 49c2938
@yannk authored
Showing with 26 additions and 3 deletions.
  1. +6 −3 lib/Test/Cukes.pm
  2. +20 −0 t/runtest.t
View
9 lib/Test/Cukes.pm
@@ -36,10 +36,13 @@ sub runtests {
my $skip_reason = "";
my $gwt;
- SKIP:
+
for my $step_text (@{$scenario->steps}) {
my ($pre, $step) = split " ", $step_text, 2;
- Test::Cukes->builder->skip($step) if $skip;
+ if ($skip) {
+ Test::Cukes->builder->skip($step_text);
+ next;
+ }
$gwt = $pre if $pre =~ /(Given|When|Then)/;
@@ -51,7 +54,7 @@ sub runtests {
eval { $cb->(@matches); };
Test::Cukes->builder->ok(!$@, $step_text);
- if ($@) {
+ if ($skip == 0 && $@) {
Test::Cukes->builder->diag($@);
$skip = 1;
$skip_reason = "Failed: $step_text";
View
20 t/runtest.t
@@ -12,6 +12,12 @@ Feature: foo
Given I will say the word 'cake'
When it is my birthday
Then we will eat 28 cakes
+
+ Scenario: Failed assertion leads to skipping remaining steps
+ Given anything
+ When I fail this step
+ Then I skip this one
+
FEATURE_TEXT
my @passed;
@@ -47,4 +53,18 @@ Then qr/we will eat (\d+) (.+)/ => sub {
. " correctly passed to the step functions";
};
+
+Given qr/anything/ => sub {
+ assert "Anything is ok";
+ ok 1, "passed Given";
+};
+
+When qr/fail/ => sub {
+ assert 0 == 1;
+};
+
+Then qr/skip/ => sub {
+ ok 0, "This shoudln't be executed at all!";
+};
+
runtests;
Please sign in to comment.
Something went wrong with that request. Please try again.