Skip to content

Commit ea86799

Browse files
committed
Improve test reporting
1 parent 30c6609 commit ea86799

File tree

7 files changed

+118
-19
lines changed

7 files changed

+118
-19
lines changed

lib/mutant/reporter/cli/printer/env_progress.rb

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,31 @@ class EnvProgress < self
1111
:amount_mutations,
1212
:amount_mutations_alive,
1313
:amount_mutations_killed,
14+
:amount_selected_tests,
1415
:amount_subjects,
16+
:amount_total_tests,
1517
:coverage,
1618
:env,
1719
:killtime,
1820
:overhead,
19-
:runtime
21+
:runtime,
22+
:test_subject_ratio
2023
)
2124

2225
FORMATS = IceNine.deep_freeze([
23-
[:info, 'Subjects: %s', :amount_subjects ],
24-
[:info, 'Mutations: %s', :amount_mutations ],
25-
[:info, 'Results: %s', :amount_mutation_results ],
26-
[:info, 'Kills: %s', :amount_mutations_killed ],
27-
[:info, 'Alive: %s', :amount_mutations_alive ],
28-
[:info, 'Runtime: %0.2fs', :runtime ],
29-
[:info, 'Killtime: %0.2fs', :killtime ],
30-
[:info, 'Overhead: %0.2f%%', :overhead_percent ],
31-
[:info, 'Mutations/s: %0.2f', :mutations_per_second ],
32-
[:status, 'Coverage: %0.2f%%', :coverage_percent ]
26+
[:info, 'Subjects: %s', :amount_subjects ],
27+
[:info, 'Total-Tests: %s', :amount_total_tests ],
28+
[:info, 'Selected-Tests: %s', :amount_selected_tests ],
29+
[:info, 'Tests/Subject: %0.2f avg', :test_subject_ratio ],
30+
[:info, 'Mutations: %s', :amount_mutations ],
31+
[:info, 'Results: %s', :amount_mutation_results ],
32+
[:info, 'Kills: %s', :amount_mutations_killed ],
33+
[:info, 'Alive: %s', :amount_mutations_alive ],
34+
[:info, 'Runtime: %0.2fs', :runtime ],
35+
[:info, 'Killtime: %0.2fs', :killtime ],
36+
[:info, 'Overhead: %0.2f%%', :overhead_percent ],
37+
[:info, 'Mutations/s: %0.2f', :mutations_per_second ],
38+
[:status, 'Coverage: %0.2f%%', :coverage_percent ]
3339
])
3440

3541
# Run printer

lib/mutant/result.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,28 @@ def amount_subjects
108108
env.subjects.length
109109
end
110110

111+
# Amount of tests reachable by integration
112+
#
113+
# @return [Integer]
114+
def amount_total_tests
115+
env.integration.all_tests.length
116+
end
117+
118+
# Amount of selected tests
119+
#
120+
# @return [Integer]
121+
def amount_selected_tests
122+
env.selections.values.flatten.to_set.length
123+
end
124+
memoize :amount_selected_tests
125+
126+
# Ratio between selected tests and subjects
127+
#
128+
# @return [Rational]
129+
def test_subject_ratio
130+
Rational(amount_selected_tests, amount_subjects)
131+
end
132+
111133
# Test if processing needs to stop
112134
#
113135
# @return [Boolean]

spec/support/shared_context.rb

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,18 @@ def setup_shared_context
5454
let(:env) do
5555
instance_double(
5656
Mutant::Env,
57-
config: config,
58-
mutations: mutations,
59-
selections: { subject_a => [test_a] },
60-
subjects: [subject_a]
57+
config: config,
58+
integration: integration,
59+
mutations: mutations,
60+
selections: { subject_a => [test_a] },
61+
subjects: [subject_a]
62+
)
63+
end
64+
65+
let(:integration) do
66+
instance_double(
67+
Mutant::Integration,
68+
all_tests: [test_a]
6169
)
6270
end
6371

spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
Includes: []
1818
Requires: []
1919
Subjects: 1
20+
Total-Tests: 1
21+
Selected-Tests: 1
22+
Tests/Subject: 1.00 avg
2023
Mutations: 2
2124
Results: 0
2225
Kills: 0
@@ -38,6 +41,9 @@
3841
Includes: []
3942
Requires: []
4043
Subjects: 1
44+
Total-Tests: 1
45+
Selected-Tests: 1
46+
Tests/Subject: 1.00 avg
4147
Mutations: 2
4248
Results: 2
4349
Kills: 2
@@ -61,6 +67,9 @@
6167
Includes: []
6268
Requires: []
6369
Subjects: 1
70+
Total-Tests: 1
71+
Selected-Tests: 1
72+
Tests/Subject: 1.00 avg
6473
Mutations: 2
6574
Results: 2
6675
Kills: 1

spec/unit/mutant/reporter/cli/printer/env_result_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
Includes: []
2929
Requires: []
3030
Subjects: 1
31+
Total-Tests: 1
32+
Selected-Tests: 1
33+
Tests/Subject: 1.00 avg
3134
Mutations: 2
3235
Results: 2
3336
Kills: 1

spec/unit/mutant/reporter/cli_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ def self.it_reports(expected_content)
8787
Includes: []
8888
Requires: []
8989
Subjects: 1
90+
Total-Tests: 1
91+
Selected-Tests: 1
92+
Tests/Subject: 1.00 avg
9093
Mutations: 2
9194
Results: 2
9295
Kills: 2

spec/unit/mutant/result/env_spec.rb

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@
1414
let(:env) do
1515
instance_double(
1616
Mutant::Env,
17-
config: instance_double(Mutant::Config, fail_fast: fail_fast),
18-
subjects: [instance_double(Mutant::Subject)],
19-
mutations: [instance_double(Mutant::Mutation)]
17+
config: instance_double(Mutant::Config, fail_fast: fail_fast),
18+
integration: integration,
19+
mutations: [instance_double(Mutant::Mutation)],
20+
selections: selections,
21+
subjects: [subject_a, subject_b]
22+
)
23+
end
24+
25+
let(:integration) do
26+
instance_double(
27+
Mutant::Integration,
28+
all_tests: [test_a, test_b]
2029
)
2130
end
2231

@@ -29,6 +38,33 @@
2938
)
3039
end
3140

41+
let(:selections) do
42+
{
43+
subject_a: [test_a],
44+
subject_b: [test_a, test_b, test_c]
45+
}
46+
end
47+
48+
let(:subject_a) do
49+
instance_double(Mutant::Subject, :a)
50+
end
51+
52+
let(:subject_b) do
53+
instance_double(Mutant::Subject, :b)
54+
end
55+
56+
let(:test_a) do
57+
instance_double(Mutant::Test, :a)
58+
end
59+
60+
let(:test_b) do
61+
instance_double(Mutant::Test, :b)
62+
end
63+
64+
let(:test_c) do
65+
instance_double(Mutant::Test, :c)
66+
end
67+
3268
let(:fail_fast) { false }
3369
let(:killed) { 0 }
3470
let(:results) { 1 }
@@ -84,7 +120,19 @@
84120
describe '#amount_subjects' do
85121
subject { object.amount_subjects }
86122

87-
it { should eql(1) }
123+
it { should eql(2) }
124+
end
125+
126+
describe '#amount_total_tests' do
127+
subject { object.amount_total_tests }
128+
129+
it { should eql(2) }
130+
end
131+
132+
describe '#test_subject_ratio' do
133+
subject { object.test_subject_ratio }
134+
135+
it { should eql(Rational(3, 2)) }
88136
end
89137

90138
describe '#stop?' do

0 commit comments

Comments
 (0)