mirror of https://github.com/briot/gnatbdd
Display the stats after execution of all features
This commit is contained in:
parent
8aca16cbcb
commit
dfdeb59b89
|
@ -64,8 +64,10 @@ switches:
|
|||
|
||||
GNATbdd displays a "." for each test that passes, a "F" for each
|
||||
test that fails (and will then display a full backtrace for those)
|
||||
and a "S" for skipped tests (and will also display more information
|
||||
for those).
|
||||
and a "S" for skipped tests.
|
||||
|
||||
When all features have run, GNATbdd displays details for all tests
|
||||
that did not pass.
|
||||
|
||||
Finally, it displays a summary for the final count for each category.
|
||||
|
||||
|
@ -96,6 +98,8 @@ switches:
|
|||
pass or fail. The output looks like the above, but instead of displaying
|
||||
a ".", GNATbdd outputs the full lists of steps for that scenario.
|
||||
|
||||
In this mode, GNATbdd outputs each step before it is being run, thus this
|
||||
allows you to monitor which step is taking long to execute.
|
||||
|
||||
Log files
|
||||
=========
|
||||
|
|
|
@ -279,6 +279,95 @@ package body BDD.Formatters is
|
|||
end if;
|
||||
end Display_Step;
|
||||
|
||||
----------------------------
|
||||
-- All_Features_Completed --
|
||||
----------------------------
|
||||
|
||||
procedure All_Features_Completed
|
||||
(Self : in out Formatter;
|
||||
Features : Natural;
|
||||
Scenarios : Count_Array;
|
||||
Steps : Count_Array;
|
||||
Elapsed : Duration)
|
||||
is
|
||||
procedure Put_Stats (Total : Natural; Stats : Count_Array);
|
||||
-- Display the stats
|
||||
|
||||
procedure Put_Stats (Total : Natural; Stats : Count_Array) is
|
||||
Is_First : Boolean := True;
|
||||
begin
|
||||
if Total /= 0 then
|
||||
Put (" (");
|
||||
|
||||
for S in Stats'Range loop
|
||||
if Stats (S) /= 0 then
|
||||
if not Is_First then
|
||||
Put (", ");
|
||||
end if;
|
||||
Is_First := False;
|
||||
|
||||
Self.Term.Set_Color
|
||||
(Term => Ada.Text_IO.Standard_Output,
|
||||
Foreground => BDD.Step_Colors (S));
|
||||
|
||||
Put (Image (Stats (S), 1));
|
||||
Put (" ");
|
||||
|
||||
case S is
|
||||
when Status_Passed => Put ("passed");
|
||||
when Status_Failed => Put ("failed");
|
||||
when Status_Skipped => Put ("skipped");
|
||||
when Status_Undefined => Put ("undefined");
|
||||
end case;
|
||||
|
||||
Self.Term.Set_Color
|
||||
(Term => Ada.Text_IO.Standard_Output,
|
||||
Style => Reset_All);
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
Put (")");
|
||||
end if;
|
||||
New_Line;
|
||||
end Put_Stats;
|
||||
|
||||
Sc_Count : Natural := 0;
|
||||
St_Count : Natural := 0;
|
||||
Minutes : Natural;
|
||||
Seconds : Duration;
|
||||
|
||||
begin
|
||||
Clear_Progress (Self);
|
||||
|
||||
for S in Scenarios'Range loop
|
||||
Sc_Count := Sc_Count + Scenarios (S);
|
||||
end loop;
|
||||
|
||||
for S in Steps'Range loop
|
||||
St_Count := St_Count + Steps (S);
|
||||
end loop;
|
||||
|
||||
New_Line;
|
||||
|
||||
Put_Line (Image (Features, 1) & " features");
|
||||
|
||||
Put (Image (Sc_Count, 1) & " scenarios");
|
||||
Put_Stats (Sc_Count, Scenarios);
|
||||
|
||||
Put (Image (St_Count, 1) & " steps");
|
||||
Put_Stats (St_Count, Steps);
|
||||
|
||||
Minutes := Integer (Elapsed / 60.0);
|
||||
Seconds := Elapsed - Duration (Minutes) * 60.0;
|
||||
|
||||
declare
|
||||
S : constant String := Seconds'Img;
|
||||
begin
|
||||
Put_Line
|
||||
(Image (Minutes, 1) & "m" & S (S'First + 1 .. S'First + 5) & "s");
|
||||
end;
|
||||
end All_Features_Completed;
|
||||
|
||||
--------------------
|
||||
-- Scenario_Start --
|
||||
--------------------
|
||||
|
@ -350,17 +439,25 @@ package body BDD.Formatters is
|
|||
----------------------------
|
||||
|
||||
overriding procedure All_Features_Completed
|
||||
(Self : in out Formatter_Dots)
|
||||
(Self : in out Formatter_Dots;
|
||||
Features : Natural;
|
||||
Scenarios : Count_Array;
|
||||
Steps : Count_Array;
|
||||
Elapsed : Duration)
|
||||
is
|
||||
begin
|
||||
Clear_Progress (Self);
|
||||
|
||||
if Self.Failed.Length /= 0 then
|
||||
New_Line;
|
||||
New_Line;
|
||||
for S of Self.Failed loop
|
||||
Display_Scenario_And_Steps (Self, S);
|
||||
end loop;
|
||||
Self.Failed.Clear;
|
||||
end if;
|
||||
|
||||
All_Features_Completed -- inherited
|
||||
(Formatter (Self), Features, Scenarios, Steps, Elapsed);
|
||||
end All_Features_Completed;
|
||||
|
||||
--------------------
|
||||
|
|
|
@ -56,7 +56,14 @@ package BDD.Formatters is
|
|||
-- Called when a step has completed.
|
||||
-- Step.Status has been set appropriately
|
||||
|
||||
procedure All_Features_Completed (Self : in out Formatter) is null;
|
||||
type Count_Array is array (Scenario_Status) of Natural;
|
||||
|
||||
procedure All_Features_Completed
|
||||
(Self : in out Formatter;
|
||||
Features : Natural;
|
||||
Scenarios : Count_Array;
|
||||
Steps : Count_Array;
|
||||
Elapsed : Duration);
|
||||
-- Called when all features have been full run.
|
||||
-- This can be used to display summaries
|
||||
|
||||
|
@ -91,7 +98,12 @@ package BDD.Formatters is
|
|||
overriding procedure Scenario_Completed
|
||||
(Self : in out Formatter_Dots;
|
||||
Scenario : BDD.Features.Scenario);
|
||||
overriding procedure All_Features_Completed (Self : in out Formatter_Dots);
|
||||
overriding procedure All_Features_Completed
|
||||
(Self : in out Formatter_Dots;
|
||||
Features : Natural;
|
||||
Scenarios : Count_Array;
|
||||
Steps : Count_Array;
|
||||
Elapsed : Duration);
|
||||
|
||||
-----------
|
||||
-- Quiet --
|
||||
|
|
|
@ -88,15 +88,44 @@ package body BDD.Runner is
|
|||
is
|
||||
begin
|
||||
if Self.Files /= null then
|
||||
Self.Run_Start;
|
||||
Self.Format := Format;
|
||||
Sort (Self.Files.all);
|
||||
for F in Self.Files'Range loop
|
||||
Parser.Parse (Self.Files (F), Self);
|
||||
end loop;
|
||||
|
||||
Self.Run_End;
|
||||
Self.Format := null;
|
||||
end if;
|
||||
end Run;
|
||||
|
||||
---------------
|
||||
-- Run_Start --
|
||||
---------------
|
||||
|
||||
procedure Run_Start (Self : in out Feature_Runner) is
|
||||
begin
|
||||
Self.Steps_Stats := (others => 0);
|
||||
Self.Scenario_Stats := (others => 0);
|
||||
Self.Features_Count := 0;
|
||||
Self.Current_Feature_Id := -1;
|
||||
Self.Start := Ada.Calendar.Clock;
|
||||
end Run_Start;
|
||||
|
||||
-------------
|
||||
-- Run_End --
|
||||
-------------
|
||||
|
||||
procedure Run_End (Self : in out Feature_Runner) is
|
||||
begin
|
||||
Self.Format.All_Features_Completed
|
||||
(Features => Self.Features_Count,
|
||||
Scenarios => Self.Scenario_Stats,
|
||||
Steps => Self.Steps_Stats,
|
||||
Elapsed => Ada.Calendar.Clock - Self.Start);
|
||||
end Run_End;
|
||||
|
||||
------------------
|
||||
-- Scenario_End --
|
||||
------------------
|
||||
|
@ -124,6 +153,8 @@ package body BDD.Runner is
|
|||
S.Set_Status (Status_Passed);
|
||||
end if;
|
||||
|
||||
Self.Steps_Stats (S.Status) := Self.Steps_Stats (S.Status) + 1;
|
||||
|
||||
Scenario.Set_Status (S.Status);
|
||||
|
||||
when Status_Failed | Status_Skipped | Status_Undefined =>
|
||||
|
@ -139,6 +170,14 @@ package body BDD.Runner is
|
|||
Self.Format.Scenario_Start (Scenario);
|
||||
Scenario.Foreach_Step (Run_Step'Access);
|
||||
Self.Format.Scenario_Completed (Scenario);
|
||||
|
||||
Self.Scenario_Stats (Scenario.Status) :=
|
||||
Self.Scenario_Stats (Scenario.Status) + 1;
|
||||
|
||||
if Scenario.Get_Feature.Id /= Self.Current_Feature_Id then
|
||||
Self.Features_Count := Self.Features_Count + 1;
|
||||
Self.Current_Feature_Id := Scenario.Get_Feature.Id;
|
||||
end if;
|
||||
end if;
|
||||
end Scenario_End;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
-- Manipulating features files
|
||||
|
||||
with Ada.Calendar; use Ada.Calendar;
|
||||
with BDD.Features; use BDD.Features;
|
||||
with BDD.Formatters; use BDD.Formatters;
|
||||
with BDD.Parser; use BDD.Parser;
|
||||
|
@ -63,6 +64,12 @@ package BDD.Runner is
|
|||
-- scenarios are run in the order they were defined in in the features
|
||||
-- file.
|
||||
|
||||
procedure Run_Start (Self : in out Feature_Runner);
|
||||
-- Called before the first feature is run
|
||||
|
||||
procedure Run_End (Self : in out Feature_Runner);
|
||||
-- Called after the last feature has been run.
|
||||
|
||||
overriding procedure Scenario_End
|
||||
(Self : in out Feature_Runner;
|
||||
Scenario : BDD.Features.Scenario);
|
||||
|
@ -71,6 +78,13 @@ private
|
|||
type Feature_Runner is new BDD.Parser.Abstract_Feature_Runner with record
|
||||
Files : GNATCOLL.VFS.File_Array_Access;
|
||||
Format : access BDD.Formatters.Formatter'Class;
|
||||
|
||||
Steps_Stats : Count_Array := (others => 0);
|
||||
Scenario_Stats : Count_Array := (others => 0);
|
||||
Features_Count : Natural := 0;
|
||||
Current_Feature_Id : Integer := -1;
|
||||
|
||||
Start : Ada.Calendar.Time;
|
||||
end record;
|
||||
|
||||
end BDD.Runner;
|
||||
|
|
|
@ -147,7 +147,6 @@ package body BDD is
|
|||
Format.Init (Term);
|
||||
|
||||
Features.Run (Format, Parser);
|
||||
Format.All_Features_Completed;
|
||||
|
||||
exception
|
||||
when GNAT.Command_Line.Exit_From_Command_Line
|
||||
|
|
Loading…
Reference in New Issue