simplecov-reports 0.0.4.ooyala
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +73 -0
- data/lib/simplecov-html-extended.rb +50 -0
- data/lib/simplecov/configuration.rb +98 -0
- data/lib/simplecov/reports.rb +5 -0
- data/lib/simplecov/reports/author_report.rb +180 -0
- data/lib/simplecov/reports/file_report.rb +97 -0
- data/lib/simplecov/reports/version.rb +5 -0
- data/lib/simplecov/source_file.rb +39 -0
- data/simplecov-reports.gemspec +29 -0
- data/test/fixtures/author_report/author_stats_file1.rb +23 -0
- data/test/fixtures/author_report/author_stats_file2.rb +26 -0
- data/test/fixtures/author_report/best_author_tolerance.rb +264 -0
- data/test/fixtures/file_report/classes_covered.rb +80 -0
- data/test/fixtures/file_report/classes_not_covered.rb +37 -0
- data/test/fixtures/file_report/classes_partially_covered.rb +11 -0
- data/test/fixtures/file_report/methods_covered.rb +38 -0
- data/test/fixtures/file_report/methods_not_covered.rb +39 -0
- data/test/fixtures/file_report/methods_partially_covered.rb +13 -0
- data/test/fixtures/line enhancer/line_enhancer_fixture.rb +1 -0
- data/test/helper.rb +19 -0
- data/test/memory_measure.rb +0 -0
- data/test/test_all_reports.rb +35 -0
- data/test/test_author_stats.rb +89 -0
- data/test/test_best_author_stage1.rb +75 -0
- data/test/test_best_author_stage2.rb +75 -0
- data/test/test_best_author_stage3.rb +86 -0
- data/test/test_best_author_stage4.rb +97 -0
- data/test/test_best_author_stage5.rb +97 -0
- data/test/test_file_reports.rb +159 -0
- data/test/test_html_reports.rb +43 -0
- data/test/test_line_enhancer.rb +26 -0
- data/views/author_report.erb +37 -0
- data/views/file_report.erb +21 -0
- metadata +203 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
# Classes Covered
|
2
|
+
|
3
|
+
# Classes with no significant lines of code
|
4
|
+
|
5
|
+
class CoveredClass_Empty_None
|
6
|
+
end
|
7
|
+
|
8
|
+
class CoveredClass_Empty_BlankLine
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
class CoveredClass_Empty_Comments
|
13
|
+
# first comment
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
# Classes with code in them
|
18
|
+
|
19
|
+
class CoveredClass_Code
|
20
|
+
def coveredClass_Code_method
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class CoveredClass_Comment_Code
|
25
|
+
# first comment
|
26
|
+
|
27
|
+
def coveredClass_Comment_Code_method
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class CoveredClass_BlankLine_Code
|
32
|
+
|
33
|
+
def coveredClass_BlankLine_Code_method
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
# Classes Covered although not actually used
|
39
|
+
|
40
|
+
# Classes with no significant lines of code
|
41
|
+
|
42
|
+
class CoveredClass_Unused_Empty_None
|
43
|
+
end
|
44
|
+
|
45
|
+
class CoveredClass_Unused_Empty_BlankLine
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
class CoveredClass_Unused_Empty_Comments
|
50
|
+
# first comment
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
# Classes with code in them
|
55
|
+
|
56
|
+
class CoveredClass_Unused_Code
|
57
|
+
def coveredClass_Unused_Code_method
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class CoveredClass_Unused_Comment_Code
|
62
|
+
# first comment
|
63
|
+
|
64
|
+
def coveredClass_Unused_Comment_Code_method
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class CoveredClass_Unused_BlankLine_Code
|
69
|
+
|
70
|
+
def coveredClass_Unused_BlankLine_Code_method
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Class that's not covered
|
75
|
+
if false
|
76
|
+
class NonCoveredClass
|
77
|
+
def non_covered_method
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
if false
|
2
|
+
# Classes Not Covered
|
3
|
+
|
4
|
+
# Classes with no significant lines of code
|
5
|
+
|
6
|
+
class NonCoveredClass_Empty_None
|
7
|
+
end
|
8
|
+
|
9
|
+
class NonCoveredClass_Empty_BlankLine
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
class NonCoveredClass_Empty_Comments
|
14
|
+
# first comment
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
# Classes with code in them
|
19
|
+
|
20
|
+
class NonCoveredClass_Code
|
21
|
+
def nonCoveredClass_Code_method
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class NonCoveredClass_Comment_Code
|
26
|
+
# first comment
|
27
|
+
|
28
|
+
def nonCoveredClass_Comment_Code_method
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class NonCoveredClass_BlankLine_Code
|
33
|
+
|
34
|
+
def nonCoveredClass_BlankLine_Code_method
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Methods Covered
|
2
|
+
|
3
|
+
|
4
|
+
class CoveredMethod
|
5
|
+
# Methods with no significant lines of code. These methods are excepted from reported not covered.
|
6
|
+
def emptyMethod
|
7
|
+
end
|
8
|
+
|
9
|
+
def emptyMethod_BlankLine
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def emptyMethod_Comments
|
14
|
+
# first comment
|
15
|
+
end
|
16
|
+
|
17
|
+
# Methods with code in them
|
18
|
+
def method_Code
|
19
|
+
method = "method_Code"
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_Comment_Code
|
23
|
+
# first comment
|
24
|
+
|
25
|
+
method = "method_Comment_Code"
|
26
|
+
end
|
27
|
+
|
28
|
+
def method_BlankLine_Code
|
29
|
+
|
30
|
+
method = "method_BlankLine_Code"
|
31
|
+
end
|
32
|
+
|
33
|
+
# Methods that are not covered, just for sakes
|
34
|
+
def non_covered_method
|
35
|
+
method = "I am not covered"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Methods Covered
|
2
|
+
|
3
|
+
|
4
|
+
class NonCoveredMethod
|
5
|
+
if false
|
6
|
+
def emptyMethod
|
7
|
+
end
|
8
|
+
|
9
|
+
def emptyMethod_BlankLine
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def emptyMethod_Comments
|
14
|
+
# first comment
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Methods with code in them
|
19
|
+
def method_Code
|
20
|
+
method = "method_Code"
|
21
|
+
end
|
22
|
+
|
23
|
+
def method_Comment_Code
|
24
|
+
# first comment
|
25
|
+
|
26
|
+
method = "method_Comment_Code"
|
27
|
+
end
|
28
|
+
|
29
|
+
def method_BlankLine_Code
|
30
|
+
|
31
|
+
method = "method_BlankLine_Code"
|
32
|
+
end
|
33
|
+
|
34
|
+
# Methods that are covered, just for sakes
|
35
|
+
def covered_method
|
36
|
+
method = "I am covered"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
line = "dummy"
|
data/test/helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
require 'simplecov'
|
5
|
+
require "simplecov/reports"
|
6
|
+
require 'simplecov-html-extended'
|
7
|
+
|
8
|
+
SimpleCov.coverage_dir('tmp/coverage')
|
9
|
+
|
10
|
+
class SimpleCov::Formatter::MergedFormatter
|
11
|
+
def format(result)
|
12
|
+
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
|
17
|
+
|
18
|
+
|
19
|
+
|
File without changes
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
use_merging true
|
5
|
+
merge_timeout 3600
|
6
|
+
|
7
|
+
add_report :type => SimpleCov::Configuration::ReportTypes::ItemsMissingCoverage::Api
|
8
|
+
add_report :type => SimpleCov::Configuration::ReportTypes::ItemsMissingCoverage::Class
|
9
|
+
add_report :type => SimpleCov::Configuration::ReportTypes::ItemsMissingCoverage::Method
|
10
|
+
add_report :type => SimpleCov::Configuration::ReportTypes::ItemsMissingCoverage::Configure
|
11
|
+
add_report(:type => SimpleCov::Configuration::ReportTypes::Author,
|
12
|
+
:sub_types => [
|
13
|
+
SimpleCov::Configuration::ReportTypes::Author::BestAuthor,
|
14
|
+
SimpleCov::Configuration::ReportTypes::Author::AuthorStats
|
15
|
+
],
|
16
|
+
:best_authors_count => 3)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Tests the scenario where all possible reports are configured
|
20
|
+
# Tests whether all the reports are generated
|
21
|
+
#TODO (rkonda, 06/27/2013): Add more tests
|
22
|
+
class TestAllReports < Test::Unit::TestCase
|
23
|
+
context "tests: " do
|
24
|
+
setup do
|
25
|
+
@result = SimpleCov.result.format!
|
26
|
+
end
|
27
|
+
|
28
|
+
context "reports" do
|
29
|
+
should "be of the expected number" do
|
30
|
+
assert_equal 5, @result.reports.count, "There should be 5 reports"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end # context "tests: " do
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
use_merging true
|
5
|
+
merge_timeout 3600
|
6
|
+
|
7
|
+
add_report(:type => SimpleCov::Configuration::ReportTypes::Author,
|
8
|
+
:sub_types => [
|
9
|
+
SimpleCov::Configuration::ReportTypes::Author::AuthorStats
|
10
|
+
]
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Execute code to get coverage
|
15
|
+
COVERAGE = "cover"
|
16
|
+
require_relative "fixtures/author_report/author_stats_file1"
|
17
|
+
require_relative "fixtures/author_report/author_stats_file2"
|
18
|
+
|
19
|
+
|
20
|
+
class TestAuthorStatsReport < Test::Unit::TestCase
|
21
|
+
context "author report" do
|
22
|
+
context "/author stats report" do
|
23
|
+
setup do
|
24
|
+
@result = SimpleCov.result.format!
|
25
|
+
@author_reports = @result.reports[0][:sub_reports]
|
26
|
+
end
|
27
|
+
|
28
|
+
should "exist" do
|
29
|
+
assert_equal 1, @author_reports.count, "best author report should be the only report"
|
30
|
+
end
|
31
|
+
|
32
|
+
should "have all authors" do
|
33
|
+
authors = @author_reports[0][:items].keys
|
34
|
+
expected_authors = ["AuthorTesterOne", "AuthorTesterTwo", "AuthorTesterThree", "AuthorTesterFour"]
|
35
|
+
assert_equal expected_authors.sort, authors.sort, "Authors should be the expected ones"
|
36
|
+
end
|
37
|
+
|
38
|
+
should "match files reported per author" do
|
39
|
+
files = @author_reports[0][:items]["AuthorTesterOne"][:files].keys.map(&:filename).
|
40
|
+
collect{ |item| item.slice(/simplecov-reports(.*)/, 1) }
|
41
|
+
expected_files = ["/test/fixtures/author_report/author_stats_file1.rb",
|
42
|
+
"/test/fixtures/author_report/author_stats_file2.rb"]
|
43
|
+
|
44
|
+
assert_equal expected_files, files,
|
45
|
+
"AuthorTesterOne's authored files don't match"
|
46
|
+
|
47
|
+
files = @author_reports[0][:items]["AuthorTesterTwo"][:files].keys.map(&:filename).
|
48
|
+
collect{ |item| item.slice(/simplecov-reports(.*)/, 1) }
|
49
|
+
expected_files = ["/test/fixtures/author_report/author_stats_file1.rb"]
|
50
|
+
|
51
|
+
assert_equal expected_files, files,
|
52
|
+
"AuthorTesterTwo's authored files don't match"
|
53
|
+
|
54
|
+
files = @author_reports[0][:items]["AuthorTesterThree"][:files].keys.map(&:filename).
|
55
|
+
collect{ |item| item.slice(/simplecov-reports(.*)/, 1) }
|
56
|
+
expected_files = ["/test/fixtures/author_report/author_stats_file2.rb"]
|
57
|
+
|
58
|
+
assert_equal expected_files, files,
|
59
|
+
"AuthorTesterThree's authored files don't match"
|
60
|
+
|
61
|
+
files = @author_reports[0][:items]["AuthorTesterFour"][:files].keys.map(&:filename).
|
62
|
+
collect{ |item| item.slice(/simplecov-reports(.*)/, 1) }
|
63
|
+
expected_files = []
|
64
|
+
|
65
|
+
assert_equal expected_files, files,
|
66
|
+
"AuthorTesterFour's authored files don't match"
|
67
|
+
end
|
68
|
+
|
69
|
+
should "match the coverage report per author per file" do
|
70
|
+
author_report = @author_reports[0][:items]["AuthorTesterOne"][:files].values
|
71
|
+
expected_author_report = [{:covered=>3, :missed=>7, :total=>10, :coverage=>30.0},
|
72
|
+
{:covered=>1, :missed=>9, :total=>10, :coverage=>10.0}]
|
73
|
+
assert_equal expected_author_report, author_report, "AuthorTesterOne's author report should match"
|
74
|
+
|
75
|
+
author_report = @author_reports[0][:items]["AuthorTesterTwo"][:files].values
|
76
|
+
expected_author_report = [{:covered=>1, :missed=>3, :total=>4, :coverage=>25.0}]
|
77
|
+
assert_equal expected_author_report, author_report, "AuthorTesterTwo's author report should match"
|
78
|
+
|
79
|
+
author_report = @author_reports[0][:items]["AuthorTesterThree"][:files].values
|
80
|
+
expected_author_report = [{:covered=>4, :missed=>0, :total=>4, :coverage=>100.0}]
|
81
|
+
assert_equal expected_author_report, author_report, "AuthorTesterThree's author report should match"
|
82
|
+
|
83
|
+
author_report = @author_reports[0][:items]["AuthorTesterFour"][:files].values
|
84
|
+
expected_author_report = []
|
85
|
+
assert_equal expected_author_report, author_report, "AuthorTesterFour's author report should match"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end # context "author report" do
|
89
|
+
end # class TestAuthorReports
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require_relative 'helper'
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
use_merging true
|
5
|
+
merge_timeout 3600
|
6
|
+
|
7
|
+
add_report(:type => SimpleCov::Configuration::ReportTypes::Author,
|
8
|
+
:sub_types => [
|
9
|
+
SimpleCov::Configuration::ReportTypes::Author::BestAuthor
|
10
|
+
],
|
11
|
+
:best_authors_count => 1)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Execute code to get coverage
|
15
|
+
COVERAGE = "cover"
|
16
|
+
require_relative "fixtures/author_report/best_author_tolerance"
|
17
|
+
|
18
|
+
# best_author_tolerance is 50%
|
19
|
+
# best_author_cutoff is 15%
|
20
|
+
# best_author_count is 3
|
21
|
+
# Author: Rajesh Konda has 10% coverage with 100 lines of code
|
22
|
+
# Author: AuthorTesterOne has 20% coverage with 70 lines of code
|
23
|
+
# Author: AuthorTesterTwo has 30% coverage with 30 lines of code
|
24
|
+
# Author: AuthorTesterThree has 40% coverage with 30 lines of code
|
25
|
+
# Author: AuthorTesterFour has 50% coverage with 10 lines of code
|
26
|
+
|
27
|
+
|
28
|
+
class TestBestAuthorReport < Test::Unit::TestCase
|
29
|
+
context "author report" do
|
30
|
+
context "/best author report" do
|
31
|
+
setup do
|
32
|
+
@result = SimpleCov.result.format!
|
33
|
+
@author_reports = @result.reports[0][:sub_reports]
|
34
|
+
end
|
35
|
+
|
36
|
+
context " when :best_authors_count=1" do
|
37
|
+
should "exist" do
|
38
|
+
assert_equal 1, @author_reports.count, "best author report should be the only report"
|
39
|
+
end
|
40
|
+
|
41
|
+
should "have authors in right order" do
|
42
|
+
authors = @author_reports[0][:items].keys
|
43
|
+
expected_authors = ["AuthorTesterOne", "Rajesh Konda"]
|
44
|
+
assert_equal expected_authors, authors, "Authors should be the expected ones"
|
45
|
+
end
|
46
|
+
|
47
|
+
should "match files reported per author" do
|
48
|
+
files = @author_reports[0][:items]["Rajesh Konda"][:files].keys.map(&:filename).
|
49
|
+
collect{ |item| item.slice(/simplecov-reports(.*)/, 1) }
|
50
|
+
expected_files = ["/test/fixtures/author_report/best_author_tolerance.rb"]
|
51
|
+
|
52
|
+
assert_equal expected_files, files,
|
53
|
+
"Rajesh Konda's authored files don't match"
|
54
|
+
|
55
|
+
files = @author_reports[0][:items]["AuthorTesterOne"][:files].keys.map(&:filename).
|
56
|
+
collect{ |item| item.slice(/simplecov-reports(.*)/, 1) }
|
57
|
+
expected_files = ["/test/fixtures/author_report/best_author_tolerance.rb"]
|
58
|
+
|
59
|
+
assert_equal expected_files, files,
|
60
|
+
"AuthorTesterOne's authored files don't match"
|
61
|
+
end
|
62
|
+
|
63
|
+
should "match the coverage report per author per file" do
|
64
|
+
author_report = @author_reports[0][:items]["Rajesh Konda"][:files].values
|
65
|
+
expected_author_report = [{:covered=>10, :missed=>90, :total=>100, :coverage=>10.0}]
|
66
|
+
assert_equal expected_author_report, author_report, "Rajesh Konda's author report should match"
|
67
|
+
|
68
|
+
author_report = @author_reports[0][:items]["AuthorTesterOne"][:files].values
|
69
|
+
expected_author_report = [{:covered=>14, :missed=>56, :total=>70, :coverage=>20.0}]
|
70
|
+
assert_equal expected_author_report, author_report, "AuthorTesterOne's author report should match"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end # context "/best author report" do
|
74
|
+
end # context "author report" do
|
75
|
+
end # class TestAuthorReports
|