@@ -6,43 +6,30 @@ class ConsoleCounts
6
6
include Console
7
7
8
8
def initialize ( config )
9
- @test_case_summary = Core ::Test ::Result ::Summary . new
10
- @test_step_summary = Core ::Test ::Result ::Summary . new
11
-
12
- config . on_event :test_case_finished do |event |
13
- event . result . describe_to @test_case_summary
14
- end
15
-
16
- config . on_event :test_step_finished do |event |
17
- event . result . describe_to @test_step_summary if from_gherkin? ( event . test_step )
18
- end
9
+ @summary = Core ::Report ::Summary . new ( config . event_bus )
19
10
end
20
11
21
12
def to_s
22
13
[
23
- [ scenario_count , status_counts ( @test_case_summary ) ] . compact . join ( ' ' ) ,
24
- [ step_count , status_counts ( @test_step_summary ) ] . compact . join ( ' ' )
14
+ [ scenario_count , status_counts ( @summary . test_cases ) ] . compact . join ( ' ' ) ,
15
+ [ step_count , status_counts ( @summary . test_steps ) ] . compact . join ( ' ' )
25
16
] . join ( "\n " )
26
17
end
27
18
28
19
private
29
20
30
- def from_gherkin? ( test_step )
31
- test_step . source . last . location . file . match ( /\. feature$/ )
32
- end
33
-
34
21
def scenario_count
35
- count = @test_case_summary . total
22
+ count = @summary . test_cases . total
36
23
"#{ count } scenario" + ( count == 1 ? '' : 's' )
37
24
end
38
25
39
26
def step_count
40
- count = @test_step_summary . total
27
+ count = @summary . test_steps . total
41
28
"#{ count } step" + ( count == 1 ? '' : 's' )
42
29
end
43
30
44
31
def status_counts ( summary )
45
- counts = [ :failed , :skipped , :undefined , :pending , :passed ] . map { |status |
32
+ counts = Core :: Test :: Result :: TYPES . map { |status |
46
33
count = summary . total ( status )
47
34
[ status , count ]
48
35
} . select { |status , count |
0 commit comments