Check whether skipped tests are actually defined

This commit is contained in:
Emmanuel Briot 2014-02-10 11:14:46 +01:00
parent 2d45334844
commit 162bfb4237
3 changed files with 62 additions and 30 deletions

View File

@ -147,36 +147,38 @@ package body BDD.Runner is
procedure Run_Step
(Scenario : BDD.Features.Scenario;
Step : not null access Step_Record'Class) is
Step : not null access Step_Record'Class)
is
Execute : constant Boolean := Scenario.Status = Status_Passed;
begin
case Scenario.Status is
when Status_Passed =>
Step.Set_Status (Status_Passed);
-- Run the step, or at least check whether it is defined.
if Execute then
Step.Set_Status (Status_Passed);
else
Step.Set_Status (Status_Skipped);
end if;
begin
BDD.Steps.Run_Step (Step);
begin
-- Will set status to undefined if necessary
BDD.Steps.Run_Step (Step, Execute => Execute);
-- if Step.Status = Status_Undefined then
-- -- ??? Could run some predefined steps here
-- null;
-- end if;
-- if Step.Status = Status_Undefined then
-- -- ??? Could run some predefined steps here
-- null;
-- end if;
exception
when E : others =>
Step.Set_Status (Status_Failed, Exception_Information (E));
end;
exception
when E : others =>
Step.Set_Status
(Status_Failed, Exception_Information (E));
end;
if Execute then
if Show_Steps then
Self.Steps_Stats (Step.Status) :=
Self.Steps_Stats (Step.Status) + 1;
end if;
if Show_Steps then
Self.Steps_Stats (Step.Status) :=
Self.Steps_Stats (Step.Status) + 1;
end if;
Scenario.Set_Status (Step.Status);
when Status_Failed | Status_Skipped | Status_Undefined =>
Step.Set_Status (Status_Skipped);
end case;
Scenario.Set_Status (Step.Status);
end if;
if Show_Steps then
Self.Format.Step_Completed (Scenario, Step);

View File

@ -29,9 +29,12 @@ package body BDD.Steps is
("^Given a user named '(.*)'$");
Re_2 : constant Pattern_Matcher := Compile
("^Given I am sitting at my desk$");
Re_3 : constant Pattern_Matcher := Compile
("^Then I should create great software$");
procedure Do_Step_1 (Name : String);
procedure Do_Step_2;
procedure Do_Step_3;
---------------
-- Do_Step_1 --
@ -52,12 +55,22 @@ package body BDD.Steps is
raise Constraint_Error;
end Do_Step_2;
---------------
-- Do_Step_3 --
---------------
procedure Do_Step_3 is
begin
raise Constraint_Error;
end Do_Step_3;
--------------
-- Run_Step --
--------------
procedure Run_Step
(Step : not null access BDD.Features.Step_Record'Class)
(Step : not null access BDD.Features.Step_Record'Class;
Execute : Boolean)
is
Text : constant String := Step.Text;
Matches : Match_Array (0 .. 10);
@ -65,14 +78,27 @@ package body BDD.Steps is
Match (Re_1, Text, Matches);
if Matches (0) /= No_Match then
Step.Set_Match_Info (Matches);
Do_Step_1 (Name => Text (Matches (1).First .. Matches (1).Last));
if Execute then
Do_Step_1 (Name => Text (Matches (1).First .. Matches (1).Last));
end if;
return;
end if;
Match (Re_2, Text, Matches);
if Matches (0) /= No_Match then
Step.Set_Match_Info (Matches);
Do_Step_2;
if Execute then
Do_Step_2;
end if;
return;
end if;
Match (Re_3, Text, Matches);
if Matches (0) /= No_Match then
Step.Set_Match_Info (Matches);
if Execute then
Do_Step_3;
end if;
return;
end if;

View File

@ -28,8 +28,12 @@ with BDD.Features; use BDD.Features;
package BDD.Steps is
procedure Run_Step (Step : not null access BDD.Features.Step_Record'Class);
-- Run a step, and sets its status
procedure Run_Step
(Step : not null access BDD.Features.Step_Record'Class;
Execute : Boolean);
-- Run a step, and sets its status.
-- If Execute is False, then we only check whether the step is known, but
-- it is not run. No exception is raised in this mode.
-- This procedure is expected to raise exceptions when a test fails.
end BDD.Steps;