albacore 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/EULA.txt +19 -0
  2. data/README.markdown +70 -0
  3. data/VERSION +1 -0
  4. data/lib/albacore.rb +9 -0
  5. data/lib/albacore/assemblyinfo.rb +104 -0
  6. data/lib/albacore/expandtemplates.rb +64 -0
  7. data/lib/albacore/msbuild.rb +63 -0
  8. data/lib/albacore/mspectestrunner.rb +33 -0
  9. data/lib/albacore/ncoverconsole.rb +64 -0
  10. data/lib/albacore/ncoverreport.rb +61 -0
  11. data/lib/albacore/ncoverreports/assemblyfilter.rb +10 -0
  12. data/lib/albacore/ncoverreports/branchcoverage.rb +10 -0
  13. data/lib/albacore/ncoverreports/classfilter.rb +9 -0
  14. data/lib/albacore/ncoverreports/codecoveragebase.rb +25 -0
  15. data/lib/albacore/ncoverreports/cyclomaticcomplexity.rb +23 -0
  16. data/lib/albacore/ncoverreports/documentfilter.rb +9 -0
  17. data/lib/albacore/ncoverreports/fullcoveragereport.rb +21 -0
  18. data/lib/albacore/ncoverreports/methodcoverage.rb +10 -0
  19. data/lib/albacore/ncoverreports/methodfilter.rb +9 -0
  20. data/lib/albacore/ncoverreports/namespacefilter.rb +9 -0
  21. data/lib/albacore/ncoverreports/reportfilterbase.rb +26 -0
  22. data/lib/albacore/ncoverreports/summaryreport.rb +22 -0
  23. data/lib/albacore/ncoverreports/symbolcoverage.rb +10 -0
  24. data/lib/albacore/nunittestrunner.rb +38 -0
  25. data/lib/albacore/sftp.rb +24 -0
  26. data/lib/albacore/sqlcmd.rb +55 -0
  27. data/lib/albacore/ssh.rb +25 -0
  28. data/lib/albacore/support/albacore_helper.rb +4 -0
  29. data/lib/albacore/support/failure.rb +22 -0
  30. data/lib/albacore/support/logging.rb +32 -0
  31. data/lib/albacore/support/runcommand.rb +45 -0
  32. data/lib/albacore/support/yamlconfig.rb +30 -0
  33. data/lib/albacore/zipdirectory.rb +55 -0
  34. data/lib/rake/assemblyinfotask.rb +22 -0
  35. data/lib/rake/expandtemplatestask.rb +21 -0
  36. data/lib/rake/msbuildtask.rb +22 -0
  37. data/lib/rake/ncoverconsoletask.rb +22 -0
  38. data/lib/rake/ncoverreporttask.rb +22 -0
  39. data/lib/rake/nunittask.rb +22 -0
  40. data/lib/rake/renametask.rb +25 -0
  41. data/lib/rake/sftptask.rb +21 -0
  42. data/lib/rake/sqlcmdtask.rb +22 -0
  43. data/lib/rake/sshtask.rb +21 -0
  44. data/lib/rake/ziptask.rb +21 -0
  45. data/rakefile.rb +144 -0
  46. data/spec/assemblyinfo_spec.rb +246 -0
  47. data/spec/assemblyinfotask_spec.rb +31 -0
  48. data/spec/expandtemplates_spec.rb +127 -0
  49. data/spec/expandtemplatestask_spec.rb +31 -0
  50. data/spec/msbuild_spec.rb +173 -0
  51. data/spec/msbuildtask_spec.rb +31 -0
  52. data/spec/ncoverconsole_spec.rb +247 -0
  53. data/spec/ncoverconsoletask_spec.rb +31 -0
  54. data/spec/ncoverreport_spec.rb +577 -0
  55. data/spec/ncoverreporttask_spec.rb +31 -0
  56. data/spec/nunittask_spec.rb +31 -0
  57. data/spec/patches/system_patch.rb +16 -0
  58. data/spec/patches/tasklib_patch.rb +12 -0
  59. data/spec/renametask_spec.rb +30 -0
  60. data/spec/sftp_spec.rb +30 -0
  61. data/spec/sftptask_spec.rb +41 -0
  62. data/spec/sqlcmd_spec.rb +139 -0
  63. data/spec/sqlcmdtask_spec.rb +31 -0
  64. data/spec/ssh_spec.rb +48 -0
  65. data/spec/sshtask_spec.rb +39 -0
  66. data/spec/support/AssemblyInfo/assemblyinfo.yml +2 -0
  67. data/spec/support/CodeCoverage/mspec/assemblies/Machine.Specifications.NUnit.dll +0 -0
  68. data/spec/support/CodeCoverage/mspec/assemblies/Machine.Specifications.dll +0 -0
  69. data/spec/support/CodeCoverage/mspec/assemblies/TestSolution.MSpecTests.dll +0 -0
  70. data/spec/support/CodeCoverage/mspec/assemblies/TestSolution.dll +0 -0
  71. data/spec/support/CodeCoverage/mspec/assemblies/nunit.framework.dll +0 -0
  72. data/spec/support/CodeCoverage/nunit/assemblies/TestSolution.Tests.dll +0 -0
  73. data/spec/support/CodeCoverage/nunit/assemblies/TestSolution.dll +0 -0
  74. data/spec/support/CodeCoverage/nunit/assemblies/nunit.framework.dll +0 -0
  75. data/spec/support/CodeCoverage/nunit/failing_assemblies/TestSolution.FailingTests.dll +0 -0
  76. data/spec/support/CodeCoverage/nunit/failing_assemblies/nunit.framework.dll +0 -0
  77. data/spec/support/CodeCoverage/report/coverage.xml +4578 -0
  78. data/spec/support/TestSolution/TestSolution.FailingTests/FailingTestFixture.cs +19 -0
  79. data/spec/support/TestSolution/TestSolution.FailingTests/Properties/AssemblyInfo.cs +36 -0
  80. data/spec/support/TestSolution/TestSolution.FailingTests/TestSolution.FailingTests.csproj +63 -0
  81. data/spec/support/TestSolution/TestSolution.MSpecTests/Properties/AssemblyInfo.cs +36 -0
  82. data/spec/support/TestSolution/TestSolution.MSpecTests/SomeSpecTest.cs +18 -0
  83. data/spec/support/TestSolution/TestSolution.MSpecTests/TestSolution.MSpecTests.csproj +77 -0
  84. data/spec/support/TestSolution/TestSolution.Tests/Properties/AssemblyInfo.cs +36 -0
  85. data/spec/support/TestSolution/TestSolution.Tests/SomeTestFixture.cs +23 -0
  86. data/spec/support/TestSolution/TestSolution.Tests/TestSolution.Tests.csproj +69 -0
  87. data/spec/support/TestSolution/TestSolution.sln +38 -0
  88. data/spec/support/TestSolution/TestSolution/Class1.cs +17 -0
  89. data/spec/support/TestSolution/TestSolution/Properties/AssemblyInfo.cs +36 -0
  90. data/spec/support/TestSolution/TestSolution/TestSolution.csproj +59 -0
  91. data/spec/support/assemblyinfotester.rb +42 -0
  92. data/spec/support/expandtemplates/datafiles/multiplevalues.yml +3 -0
  93. data/spec/support/expandtemplates/datafiles/multitemplate-specificfile.yml +11 -0
  94. data/spec/support/expandtemplates/datafiles/multitemplate.yml +4 -0
  95. data/spec/support/expandtemplates/datafiles/sample.yml +1 -0
  96. data/spec/support/expandtemplates/templates/multipleinstance.config +4 -0
  97. data/spec/support/expandtemplates/templates/multiplevalues.config +1 -0
  98. data/spec/support/expandtemplates/templates/sample.config +1 -0
  99. data/spec/support/expandtemplatestestdata.rb +69 -0
  100. data/spec/support/msbuildtestdata.rb +32 -0
  101. data/spec/support/ncoverreporttestdata.rb +26 -0
  102. data/spec/support/spec_helper.rb +15 -0
  103. data/spec/support/test.yml +4 -0
  104. data/spec/support/zip/files/subfolder/sub file.txt +1 -0
  105. data/spec/support/zip/files/testfile.txt +1 -0
  106. data/spec/support/ziptestdata.rb +8 -0
  107. data/spec/yamlconfig_spec.rb +62 -0
  108. data/spec/zip_spec.rb +18 -0
  109. data/spec/ziptask_spec.rb +31 -0
  110. data/yaml_autoconfig_test.yml +1 -0
  111. metadata +262 -0
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'albacore/msbuild'
3
+ require 'rake/msbuildtask'
4
+ require 'tasklib_patch'
5
+
6
+ describe Albacore::MSBuildTask, "when running" do
7
+ before :all do
8
+ task = Albacore::MSBuildTask.new() do |t|
9
+ @yielded_object = t
10
+ end
11
+ task.extend(TasklibPatch)
12
+ Rake::Task[:msbuild].invoke
13
+ end
14
+
15
+ it "should yield the msbuild api" do
16
+ @yielded_object.kind_of?(MSBuild).should == true
17
+ end
18
+ end
19
+
20
+ describe Albacore::MSBuildTask, "when execution fails" do
21
+ before :all do
22
+ @task = Albacore::MSBuildTask.new(:failingtask)
23
+ @task.extend(TasklibPatch)
24
+ @task.fail
25
+ Rake::Task["failingtask"].invoke
26
+ end
27
+
28
+ it "should fail the rake task" do
29
+ @task.task_failed.should == true
30
+ end
31
+ end
@@ -0,0 +1,247 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'albacore/ncoverconsole'
3
+ require 'albacore/nunittestrunner'
4
+ require 'albacore/mspectestrunner'
5
+
6
+ @@ncoverpath = File.join(File.dirname(__FILE__), 'support', 'Tools', 'NCover-v3.3', 'NCover.Console.exe')
7
+ @@nunitpath = File.join(File.dirname(__FILE__), 'support', 'Tools', 'NUnit-v2.5', 'nunit-console-x86.exe')
8
+ @@xml_coverage_output = File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'CodeCoverage', 'nunit', 'test-coverage.xml')
9
+ @@html_coverage_output = File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'CodeCoverage', 'nunit', 'html', 'test-coverage.html')
10
+ @@working_directory = File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'CodeCoverage', 'nunit')
11
+ @@test_assembly = File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'CodeCoverage', 'nunit', 'assemblies', 'TestSolution.Tests.dll')
12
+ @@failing_test_assembly = File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'CodeCoverage', 'nunit', 'failing_assemblies', 'TestSolution.FailingTests.dll')
13
+
14
+ @@mspecpath = File.join(File.dirname(__FILE__), 'support', 'Tools', 'Machine.Specification-v0.2', 'Machine.Specifications.ConsoleRunner.exe')
15
+ @@mspec_html_output = File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'CodeCoverage', 'mspec', 'html')
16
+ @@mspec_test_assembly = File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'CodeCoverage', 'mspec', 'assemblies', 'TestSolution.MSpecTests.dll')
17
+
18
+ describe NCoverConsole, "when specifying aseemblies to cover" do
19
+ before :all do
20
+ File.delete(@@xml_coverage_output) if File.exist?(@@xml_coverage_output)
21
+
22
+ ncc = NCoverConsole.new()
23
+
24
+ ncc.extend(SystemPatch)
25
+ ncc.log_level = :verbose
26
+ ncc.path_to_command = @@ncoverpath
27
+ ncc.output = {:xml => @@xml_coverage_output}
28
+ ncc.working_directory = @@working_directory
29
+ ncc.cover_assemblies << "TestSolution"
30
+
31
+ nunit = NUnitTestRunner.new(@@nunitpath)
32
+ nunit.assemblies << @@test_assembly
33
+ nunit.options << '/noshadow'
34
+
35
+ ncc.testrunner = nunit
36
+ ncc.run
37
+ end
38
+
39
+ it "should provide coverage for the specified assemblies" do
40
+ $system_command.should include("//assemblies \"TestSolution\"")
41
+ end
42
+ end
43
+
44
+ describe NCoverConsole, "when specifying aseemblies to ignore" do
45
+ before :all do
46
+ File.delete(@@xml_coverage_output) if File.exist?(@@xml_coverage_output)
47
+
48
+ ncc = NCoverConsole.new()
49
+
50
+ ncc.extend(SystemPatch)
51
+ ncc.log_level = :verbose
52
+ ncc.path_to_command = @@ncoverpath
53
+ ncc.output = {:xml => @@xml_coverage_output}
54
+ ncc.working_directory = @@working_directory
55
+ ncc.ignore_assemblies << "TestSolution.*"
56
+
57
+ nunit = NUnitTestRunner.new(@@nunitpath)
58
+ nunit.assemblies << @@test_assembly
59
+ nunit.options << '/noshadow'
60
+
61
+ ncc.testrunner = nunit
62
+ ncc.run
63
+ end
64
+
65
+ it "should provide coverage for the specified assemblies" do
66
+ $system_command.should include("//exclude-assemblies \"TestSolution.*\"")
67
+ end
68
+ end
69
+
70
+ describe NCoverConsole, "when specifying the types of coverage to analyze" do
71
+ before :all do
72
+ File.delete(@@xml_coverage_output) if File.exist?(@@xml_coverage_output)
73
+
74
+ ncc = NCoverConsole.new()
75
+
76
+ ncc.extend(SystemPatch)
77
+ ncc.log_level = :verbose
78
+ ncc.path_to_command = @@ncoverpath
79
+ ncc.output = {:xml => @@xml_coverage_output}
80
+ ncc.working_directory = @@working_directory
81
+ ncc.coverage = [:Symbol, :Branch, :MethodVisits, :CyclomaticComplexity]
82
+
83
+ nunit = NUnitTestRunner.new(@@nunitpath)
84
+ nunit.assemblies << @@test_assembly
85
+ nunit.options << '/noshadow'
86
+
87
+ ncc.testrunner = nunit
88
+ ncc.run
89
+ end
90
+
91
+ it "should only run coverage for those metrics" do
92
+ $system_command.should include("//coverage-type \"Symbol, Branch, MethodVisits, CyclomaticComplexity\"")
93
+ end
94
+ end
95
+
96
+ describe NCoverConsole, "when analyzing a test suite with failing tests" do
97
+ before :all do
98
+ File.delete(@@xml_coverage_output) if File.exist?(@@xml_coverage_output)
99
+
100
+ ncc = NCoverConsole.new()
101
+ strio = StringIO.new
102
+ ncc.log_device = strio
103
+
104
+ ncc.extend(SystemPatch)
105
+ ncc.log_level = :verbose
106
+ ncc.path_to_command = @@ncoverpath
107
+ ncc.output = {:xml => @@xml_coverage_output}
108
+ ncc.working_directory = @@working_directory
109
+
110
+ nunit = NUnitTestRunner.new(@@nunitpath)
111
+ nunit.assemblies << @@failing_test_assembly
112
+ nunit.options << '/noshadow'
113
+
114
+ ncc.testrunner = nunit
115
+
116
+ ncc.run
117
+ @failed = ncc.failed
118
+ @log_data = strio.string
119
+ end
120
+
121
+ it "should return a failure code" do
122
+ @failed.should == true
123
+ end
124
+
125
+ it "should log a failure message" do
126
+ @log_data.should include("Code Coverage Analysis Failed. See Build Log For Detail.")
127
+ end
128
+ end
129
+
130
+ describe NCoverConsole, "when running without a testrunner" do
131
+ before :all do
132
+ ncc = NCoverConsole.new()
133
+ strio = StringIO.new
134
+ ncc.log_device = strio
135
+
136
+ @result = ncc.run
137
+ @log_data = strio.string
138
+ end
139
+
140
+ it "should log a message saying the test runner is required" do
141
+ @log_data.should include("testrunner cannot be nil.")
142
+ end
143
+
144
+ it "should return a failure code" do
145
+ @result.should == false
146
+ end
147
+ end
148
+
149
+ describe NCoverConsole, "when producing an xml coverage report with nunit" do
150
+ before :all do
151
+ File.delete(@@xml_coverage_output) if File.exist?(@@xml_coverage_output)
152
+
153
+ ncc = NCoverConsole.new()
154
+
155
+ ncc.extend(SystemPatch)
156
+ ncc.log_level = :verbose
157
+ ncc.path_to_command = @@ncoverpath
158
+ ncc.output = {:xml => @@xml_coverage_output}
159
+ ncc.working_directory = @@working_directory
160
+
161
+ nunit = NUnitTestRunner.new(@@nunitpath)
162
+ nunit.assemblies << @@test_assembly
163
+ nunit.options << '/noshadow'
164
+
165
+ ncc.testrunner = nunit
166
+ ncc.run
167
+ end
168
+
169
+ it "should execute ncover.console from the specified path" do
170
+ $system_command.should include(@@ncoverpath)
171
+ end
172
+
173
+ it "should execute with the specified working directory" do
174
+ $system_command.should include(@@working_directory)
175
+ end
176
+
177
+ it "should execute the test runner from the specified path" do
178
+ $system_command.should include(@@nunitpath)
179
+ end
180
+
181
+ it "should pass the specified arguments to the test runner" do
182
+ $system_command.should include("TestSolution.Tests.dll /noshadow")
183
+ end
184
+
185
+ it "should write the coverage data to the specified file" do
186
+ File.exist?(@@xml_coverage_output).should == true
187
+ end
188
+ end
189
+
190
+ describe NCoverConsole, "when specifying an html report and an xml coverage report with nunit" do
191
+ before :all do
192
+ File.delete(@@xml_coverage_output) if File.exist?(@@xml_coverage_output)
193
+ File.delete(@@html_coverage_output) if File.exist?(@@html_coverage_output)
194
+
195
+ ncc = NCoverConsole.new()
196
+
197
+ ncc.extend(SystemPatch)
198
+ ncc.log_level = :verbose
199
+ ncc.path_to_command = @@ncoverpath
200
+ ncc.output = {:xml => @@xml_coverage_output, :html => @@html_coverage_output}
201
+ ncc.working_directory = @@working_directory
202
+
203
+ nunit = NUnitTestRunner.new(@@nunitpath)
204
+ nunit.assemblies << @@test_assembly
205
+ nunit.options << '/noshadow'
206
+
207
+ ncc.testrunner = nunit
208
+ ncc.run
209
+ end
210
+
211
+
212
+ it "should produce the xml report" do
213
+ File.exist?(@@xml_coverage_output).should == true
214
+ end
215
+
216
+ it "should produce the html report" do
217
+ File.exist?(@@html_coverage_output).should == true
218
+ end
219
+ end
220
+
221
+ describe NCoverConsole, "when producing a report with machine.specifications" do
222
+ before :all do
223
+ @ncc = NCoverConsole.new()
224
+
225
+ @ncc.extend(SystemPatch)
226
+ @ncc.log_level = :verbose
227
+ @ncc.path_to_command = @@ncoverpath
228
+ @ncc.output = {:xml => @@xml_coverage_output}
229
+ @ncc.working_directory = @@working_directory
230
+
231
+ mspec = MSpecTestRunner.new(@@mspecpath)
232
+ mspec.assemblies << @@mspec_test_assembly
233
+ mspec.html_output = @@mspec_html_output
234
+
235
+ @ncc.testrunner = mspec
236
+ @ncc.run
237
+ end
238
+
239
+ it "should not fail" do
240
+ @ncc.failed.should be_false
241
+ end
242
+
243
+ it "should produce the html report" do
244
+ File.exist?(@@mspec_html_output.to_s).should be_true
245
+ end
246
+
247
+ end
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'albacore/ncoverconsole'
3
+ require 'rake/ncoverconsoletask'
4
+ require 'tasklib_patch'
5
+
6
+ describe Albacore::NCoverConsoleTask, "when running" do
7
+ before :all do
8
+ task = Albacore::NCoverConsoleTask.new() do |t|
9
+ @yielded_object = t
10
+ end
11
+ task.extend(TasklibPatch)
12
+ Rake::Task[:ncoverconsole].invoke
13
+ end
14
+
15
+ it "should yield the ncover console api" do
16
+ @yielded_object.kind_of?(NCoverConsole).should == true
17
+ end
18
+ end
19
+
20
+ describe Albacore::NCoverConsoleTask, "when execution fails" do
21
+ before :all do
22
+ @task = Albacore::NCoverConsoleTask.new(:failingtask)
23
+ @task.extend(TasklibPatch)
24
+ @task.fail
25
+ Rake::Task["failingtask"].invoke
26
+ end
27
+
28
+ it "should fail the rake task" do
29
+ @task.task_failed.should == true
30
+ end
31
+ end
@@ -0,0 +1,577 @@
1
+ require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
2
+ require 'albacore/ncoverreport'
3
+ require 'ncoverreporttestdata'
4
+
5
+ describe NCoverReport, "when runnign without the ncover report location specified" do
6
+ before :all do
7
+ @ncover = NCoverReport.new
8
+ @ncover.run
9
+ end
10
+
11
+ it "should fail execution" do
12
+ @ncover.failed.should be_true
13
+ end
14
+ end
15
+
16
+ describe NCoverReport, "when running a full coverage report with a specified output folder" do
17
+ before :all do
18
+ NCoverReportTestData.clean_output_folder
19
+
20
+ ncover = NCoverReport.new
21
+ ncover.extend(SystemPatch)
22
+ ncover.log_level = :verbose
23
+
24
+ ncover.path_to_command = NCoverReportTestData.path_to_command
25
+ ncover.coverage_files << NCoverReportTestData.coverage_file
26
+
27
+ fullcoveragereport = NCover::FullCoverageReport.new()
28
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
29
+ ncover.reports << fullcoveragereport
30
+
31
+ ncover.run
32
+ end
33
+
34
+ it "should execute ncover.reporting" do
35
+ $system_command.should include(NCoverReportTestData.path_to_command)
36
+ end
37
+
38
+ it "should tell ncover.reporting to produce a full coverage html report in the specified folder" do
39
+ $system_command.should include("//or FullCoverageReport:Html:\"#{NCoverReportTestData.output_folder}\"")
40
+ end
41
+
42
+ it "should produce the report" do
43
+ File.exist?(File.join(NCoverReportTestData.output_folder, "fullcoveragereport.html")).should be_true
44
+ end
45
+ end
46
+
47
+ describe NCoverReport, "when running a summary report with a specified output folder" do
48
+ before :all do
49
+ NCoverReportTestData.clean_output_folder
50
+
51
+ ncover = NCoverReport.new
52
+ ncover.extend(SystemPatch)
53
+ ncover.log_level = :verbose
54
+
55
+ ncover.path_to_command = NCoverReportTestData.path_to_command
56
+ ncover.coverage_files << NCoverReportTestData.coverage_file
57
+
58
+ summaryreport = NCover::SummaryReport.new()
59
+ summaryreport.output_path = NCoverReportTestData.summary_output_file
60
+ ncover.reports << summaryreport
61
+
62
+ ncover.run
63
+ end
64
+
65
+ it "should execute ncover.reporting" do
66
+ $system_command.should include(NCoverReportTestData.path_to_command)
67
+ end
68
+
69
+ it "should tell ncover.reporting to produce a summary html report in the specified folder" do
70
+ $system_command.should include("//or Summary:Html:\"#{NCoverReportTestData.summary_output_file}\"")
71
+ end
72
+
73
+ it "should produce the report" do
74
+ File.exist?(NCoverReportTestData.summary_output_file).should be_true
75
+ end
76
+ end
77
+
78
+ describe NCoverReport, "when running multiple ncover reports - a summary and a full coverage report" do
79
+ before :all do
80
+ NCoverReportTestData.clean_output_folder
81
+
82
+ ncover = NCoverReport.new
83
+ ncover.extend(SystemPatch)
84
+ ncover.log_level = :verbose
85
+
86
+ ncover.path_to_command = NCoverReportTestData.path_to_command
87
+ ncover.coverage_files << NCoverReportTestData.coverage_file
88
+
89
+ summaryreport = NCover::SummaryReport.new()
90
+ summaryreport.output_path = NCoverReportTestData.summary_output_file
91
+ ncover.reports << summaryreport
92
+
93
+ fullcoveragereport = NCover::FullCoverageReport.new()
94
+ @fullcoverage_output_folder = File.join(NCoverReportTestData.output_folder, "fullcoverage")
95
+ fullcoveragereport.output_path = @fullcoverage_output_folder
96
+ ncover.reports << fullcoveragereport
97
+
98
+ ncover.run
99
+ end
100
+
101
+ it "should tell ncover.reporting to produce a full coverage html report in the specified folder" do
102
+ $system_command.should include("//or FullCoverageReport:Html:\"#{@fullcoverage_output_folder}\"")
103
+ end
104
+
105
+ it "should tell ncover.reporting to produce a summary html report in the specified folder" do
106
+ $system_command.should include("//or Summary:Html:\"#{NCoverReportTestData.summary_output_file}\"")
107
+ end
108
+ end
109
+
110
+ describe NCoverReport, "when running a report with a specified minimum symbol coverage lower than actual coverage" do
111
+ before :all do
112
+ NCoverReportTestData.clean_output_folder
113
+
114
+ @ncover = NCoverReport.new
115
+ @ncover.extend(SystemPatch)
116
+ @ncover.log_level = :verbose
117
+
118
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
119
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
120
+
121
+ fullcoveragereport = NCover::FullCoverageReport.new
122
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
123
+ @ncover.reports << fullcoveragereport
124
+
125
+ symbolcoverage = NCover::SymbolCoverage.new
126
+ symbolcoverage.minimum = 10
127
+ @ncover.required_coverage << symbolcoverage
128
+
129
+ @ncover.run
130
+ end
131
+
132
+ it "should tell ncover.reporting to check for the specified minimum coverage" do
133
+ $system_command.should include("//mc SymbolCoverage:10:View")
134
+ end
135
+
136
+ it "should not fail the execution" do
137
+ @ncover.failed.should be_false
138
+ end
139
+
140
+ it "should produce the report" do
141
+ File.exist?(File.join(NCoverReportTestData.output_folder, "fullcoveragereport.html")).should be_true
142
+ end
143
+ end
144
+
145
+ describe NCoverReport, "when running a report with a specified minimum symbol coverage higher than actual coverage" do
146
+ before :all do
147
+ NCoverReportTestData.clean_output_folder
148
+
149
+ @ncover = NCoverReport.new
150
+ @ncover.extend(SystemPatch)
151
+ @ncover.log_level = :verbose
152
+
153
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
154
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
155
+
156
+ fullcoveragereport = NCover::FullCoverageReport.new
157
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
158
+ @ncover.reports << fullcoveragereport
159
+
160
+ symbolcoverage = NCover::SymbolCoverage.new
161
+ symbolcoverage.minimum = 100
162
+ @ncover.required_coverage << symbolcoverage
163
+
164
+ @ncover.run
165
+ end
166
+
167
+ it "should tell ncover.reporting to check for the specified minimum coverage" do
168
+ $system_command.should include("//mc SymbolCoverage:10")
169
+ end
170
+
171
+ it "should fail the execution" do
172
+ @ncover.failed.should be_true
173
+ end
174
+
175
+ it "should produce the report" do
176
+ File.exist?(File.join(NCoverReportTestData.output_folder, "fullcoveragereport.html")).should be_true
177
+ end
178
+ end
179
+
180
+ describe NCoverReport, "when specifying the coverage item type to check" do
181
+ before :all do
182
+ NCoverReportTestData.clean_output_folder
183
+
184
+ @ncover = NCoverReport.new
185
+ @ncover.extend(SystemPatch)
186
+ @ncover.log_level = :verbose
187
+
188
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
189
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
190
+
191
+ report = NCover::SummaryReport.new
192
+ report.output_path = NCoverReportTestData.summary_output_file
193
+ @ncover.reports << report
194
+
195
+ symbolcoverage = NCover::SymbolCoverage.new
196
+ symbolcoverage.minimum = 10
197
+ symbolcoverage.item_type = :Class
198
+ @ncover.required_coverage << symbolcoverage
199
+
200
+ @ncover.run
201
+ end
202
+
203
+ it "should tell ncover.reporting to check for the specified item type" do
204
+ $system_command.should include("//mc SymbolCoverage:10:Class")
205
+ end
206
+
207
+ it "should produce the report" do
208
+ File.exist?(NCoverReportTestData.summary_output_file).should be_true
209
+ end
210
+ end
211
+
212
+ describe NCoverReport, "when checking more than one type of coverage and all fail" do
213
+ before :all do
214
+ NCoverReportTestData.clean_output_folder
215
+
216
+ @ncover = NCoverReport.new
217
+ @ncover.extend(SystemPatch)
218
+ @ncover.log_level = :verbose
219
+
220
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
221
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
222
+
223
+ fullcoveragereport = NCover::FullCoverageReport.new
224
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
225
+ @ncover.reports << fullcoveragereport
226
+
227
+ @ncover.required_coverage << NCover::SymbolCoverage.new(:minimum => 100, :item_type => :View)
228
+ @ncover.required_coverage << NCover::BranchCoverage.new(:minimum => 10, :item_type => :Class)
229
+ @ncover.required_coverage << NCover::MethodCoverage.new(:minimum => 100, :item_type => :Class)
230
+
231
+ @ncover.run
232
+ end
233
+
234
+ it "should tell ncover.reporting to check for the symbol coverage" do
235
+ $system_command.should include("//mc SymbolCoverage:100:View")
236
+ end
237
+
238
+ it "should tell ncover.reporting to check for the branch coverage" do
239
+ $system_command.should include("//mc BranchCoverage:10:Class")
240
+ end
241
+
242
+ it "should tell ncover.reporting to check for the branch coverage" do
243
+ $system_command.should include("//mc MethodCoverage:100:Class")
244
+ end
245
+
246
+ it "should produce the report" do
247
+ File.exist?(File.join(NCoverReportTestData.output_folder, "fullcoveragereport.html")).should be_true
248
+ end
249
+
250
+ it "should fail the execution" do
251
+ @ncover.failed.should be_true
252
+ end
253
+ end
254
+
255
+ describe NCoverReport, "when checking more than one type of coverage and all pass" do
256
+ before :all do
257
+ NCoverReportTestData.clean_output_folder
258
+
259
+ @ncover = NCoverReport.new
260
+ @ncover.extend(SystemPatch)
261
+ @ncover.log_level = :verbose
262
+
263
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
264
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
265
+
266
+ fullcoveragereport = NCover::FullCoverageReport.new
267
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
268
+ @ncover.reports << fullcoveragereport
269
+
270
+ @ncover.required_coverage << NCover::SymbolCoverage.new(:minimum => 0, :item_type => :View)
271
+ @ncover.required_coverage << NCover::BranchCoverage.new(:minimum => 0, :item_type => :Class)
272
+ @ncover.required_coverage << NCover::MethodCoverage.new(:minimum => 0, :item_type => :Class)
273
+
274
+ @ncover.run
275
+ end
276
+
277
+ it "should tell ncover.reporting to check for the symbol coverage" do
278
+ $system_command.should include("//mc SymbolCoverage:0:View")
279
+ end
280
+
281
+ it "should tell ncover.reporting to check for the branch coverage" do
282
+ $system_command.should include("//mc BranchCoverage:0:Class")
283
+ end
284
+
285
+ it "should tell ncover.reporting to check for the method coverage" do
286
+ $system_command.should include("//mc MethodCoverage:0:Class")
287
+ end
288
+
289
+ it "should produce the report" do
290
+ File.exist?(File.join(NCoverReportTestData.output_folder, "fullcoveragereport.html")).should be_true
291
+ end
292
+
293
+ it "should not fail the execution" do
294
+ @ncover.failed.should be_false
295
+ end
296
+ end
297
+
298
+ describe NCoverReport, "when checking more than one type of coverage and one fails" do
299
+ before :all do
300
+ NCoverReportTestData.clean_output_folder
301
+
302
+ @ncover = NCoverReport.new
303
+ @ncover.extend(SystemPatch)
304
+ @ncover.log_level = :verbose
305
+
306
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
307
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
308
+
309
+ fullcoveragereport = NCover::FullCoverageReport.new
310
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
311
+ @ncover.reports << fullcoveragereport
312
+
313
+ @ncover.required_coverage << NCover::SymbolCoverage.new(:minimum => 100, :item_type => :View)
314
+ @ncover.required_coverage << NCover::BranchCoverage.new(:minimum => 0, :item_type => :Class)
315
+
316
+ @ncover.run
317
+ end
318
+
319
+ it "should tell ncover.reporting to check for the symbol coverage" do
320
+ $system_command.should include("//mc SymbolCoverage:100:View")
321
+ end
322
+
323
+ it "should tell ncover.reporting to check for the branch coverage" do
324
+ $system_command.should include("//mc BranchCoverage:0:Class")
325
+ end
326
+
327
+ it "should produce the report" do
328
+ File.exist?(File.join(NCoverReportTestData.output_folder, "fullcoveragereport.html")).should be_true
329
+ end
330
+
331
+ it "should fail the execution" do
332
+ @ncover.failed.should be_true
333
+ end
334
+ end
335
+
336
+ describe NCoverReport, "when running a report with a cyclomatic complexity higher than allowed" do
337
+ before :all do
338
+ NCoverReportTestData.clean_output_folder
339
+
340
+ @ncover = NCoverReport.new
341
+ @ncover.extend(SystemPatch)
342
+ @ncover.log_level = :verbose
343
+
344
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
345
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
346
+
347
+ fullcoveragereport = NCover::FullCoverageReport.new
348
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
349
+ @ncover.reports << fullcoveragereport
350
+
351
+ coverage = NCover::CyclomaticComplexity.new(:maximum => 1, :item_type => :Class)
352
+ @ncover.required_coverage << coverage
353
+
354
+ @ncover.run
355
+ end
356
+
357
+ it "should tell ncover.reporting to check for the maximum cyclomatic complexity" do
358
+ $system_command.should include("//mc CyclomaticComplexity:1:Class")
359
+ end
360
+
361
+ it "should fail the execution" do
362
+ @ncover.failed.should be_true
363
+ end
364
+
365
+ it "should produce the report" do
366
+ File.exist?(File.join(NCoverReportTestData.output_folder, "fullcoveragereport.html")).should be_true
367
+ end
368
+ end
369
+
370
+ describe NCoverReport, "when running a report with a cyclomatic complexity under the limit" do
371
+ before :all do
372
+ NCoverReportTestData.clean_output_folder
373
+
374
+ @ncover = NCoverReport.new
375
+ @ncover.extend(SystemPatch)
376
+ @ncover.log_level = :verbose
377
+
378
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
379
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
380
+
381
+ fullcoveragereport = NCover::FullCoverageReport.new
382
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
383
+ @ncover.reports << fullcoveragereport
384
+
385
+ coverage = NCover::CyclomaticComplexity.new(:maximum => 1000)
386
+ @ncover.required_coverage << coverage
387
+
388
+ @ncover.run
389
+ end
390
+
391
+ it "should tell ncover.reporting to check for the maximum cyclomatic complexity" do
392
+ $system_command.should include("//mc CyclomaticComplexity:1000:View")
393
+ end
394
+
395
+ it "should not fail the execution" do
396
+ @ncover.failed.should be_false
397
+ end
398
+
399
+ it "should produce the report" do
400
+ File.exist?(File.join(NCoverReportTestData.output_folder, "fullcoveragereport.html")).should be_true
401
+ end
402
+ end
403
+
404
+ describe NCoverReport, "when filtering on Assembly coverage data" do
405
+ before :all do
406
+ NCoverReportTestData.clean_output_folder
407
+
408
+ @ncover = NCoverReport.new
409
+ @ncover.extend(SystemPatch)
410
+ @ncover.log_level = :verbose
411
+
412
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
413
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
414
+
415
+ fullcoveragereport = NCover::FullCoverageReport.new
416
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
417
+ @ncover.reports << fullcoveragereport
418
+ @ncover.required_coverage << NCover::SymbolCoverage.new(:minimum => 0)
419
+
420
+ @ncover.filters << NCover::AssemblyFilter.new(:filter_type => :exclude, :filter => ["nunit.*"])
421
+ @ncover.filters << NCover::AssemblyFilter.new(:filter_type => :include, :filter => ["TestSolution.*"])
422
+
423
+ @ncover.run
424
+ end
425
+
426
+ it "should exclude the specified assemblies data" do
427
+ $system_command.should include("//cf \"nunit.*\":Assembly:false:false")
428
+ end
429
+
430
+ it "should include the specified assemblies data" do
431
+ $system_command.should include("//cf \"TestSolution.*\":Assembly:false:true")
432
+ end
433
+
434
+ it "should not fail" do
435
+ @ncover.failed.should be_false
436
+ end
437
+ end
438
+
439
+ describe NCoverReport, "when filtering on Namespace coverage data" do
440
+ before :all do
441
+ NCoverReportTestData.clean_output_folder
442
+
443
+ @ncover = NCoverReport.new
444
+ @ncover.extend(SystemPatch)
445
+ @ncover.log_level = :verbose
446
+
447
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
448
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
449
+
450
+ fullcoveragereport = NCover::FullCoverageReport.new
451
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
452
+ @ncover.reports << fullcoveragereport
453
+ @ncover.required_coverage << NCover::SymbolCoverage.new(:minimum => 0)
454
+
455
+ @ncover.filters << NCover::NamespaceFilter.new(:filter_type => :exclude, :filter => ["nunit.*"])
456
+ @ncover.filters << NCover::NamespaceFilter.new(:filter_type => :include, :filter => ["TestSolution.*"])
457
+
458
+ @ncover.run
459
+ end
460
+
461
+ it "should exclude the specified data" do
462
+ $system_command.should include("//cf \"nunit.*\":Namespace:false:false")
463
+ end
464
+
465
+ it "should include the specified data" do
466
+ $system_command.should include("//cf \"TestSolution.*\":Namespace:false:true")
467
+ end
468
+
469
+ it "should not fail" do
470
+ @ncover.failed.should be_false
471
+ end
472
+ end
473
+
474
+ describe NCoverReport, "when filtering on Class coverage data" do
475
+ before :all do
476
+ NCoverReportTestData.clean_output_folder
477
+
478
+ @ncover = NCoverReport.new
479
+ @ncover.extend(SystemPatch)
480
+ @ncover.log_level = :verbose
481
+
482
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
483
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
484
+
485
+ fullcoveragereport = NCover::FullCoverageReport.new
486
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
487
+ @ncover.reports << fullcoveragereport
488
+ @ncover.required_coverage << NCover::SymbolCoverage.new(:minimum => 0)
489
+
490
+ @ncover.filters << NCover::ClassFilter.new(:filter_type => :exclude, :filter => ["Foo"])
491
+ @ncover.filters << NCover::ClassFilter.new(:filter_type => :include, :filter => ["Bar"])
492
+
493
+ @ncover.run
494
+ end
495
+
496
+ it "should exclude the specified data" do
497
+ $system_command.should include("//cf \"Foo\":Class:false:false")
498
+ end
499
+
500
+ it "should include the specified data" do
501
+ $system_command.should include("//cf \"Bar\":Class:false:true")
502
+ end
503
+
504
+ it "should not fail" do
505
+ @ncover.failed.should be_false
506
+ end
507
+ end
508
+
509
+ describe NCoverReport, "when filtering on Method coverage data" do
510
+ before :all do
511
+ NCoverReportTestData.clean_output_folder
512
+
513
+ @ncover = NCoverReport.new
514
+ @ncover.extend(SystemPatch)
515
+ @ncover.log_level = :verbose
516
+
517
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
518
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
519
+
520
+ fullcoveragereport = NCover::FullCoverageReport.new
521
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
522
+ @ncover.reports << fullcoveragereport
523
+ @ncover.required_coverage << NCover::SymbolCoverage.new(:minimum => 0)
524
+
525
+ @ncover.filters << NCover::MethodFilter.new(:filter_type => :exclude, :filter => ["Foo"])
526
+ @ncover.filters << NCover::MethodFilter.new(:filter_type => :include, :filter => ["Bar"])
527
+
528
+ @ncover.run
529
+ end
530
+
531
+ it "should exclude the specified data" do
532
+ $system_command.should include("//cf \"Foo\":Method:false:false")
533
+ end
534
+
535
+ it "should include the specified data" do
536
+ $system_command.should include("//cf \"Bar\":Method:false:true")
537
+ end
538
+
539
+ it "should not fail" do
540
+ @ncover.failed.should be_false
541
+ end
542
+ end
543
+
544
+ describe NCoverReport, "when filtering on Document coverage data" do
545
+ before :all do
546
+ NCoverReportTestData.clean_output_folder
547
+
548
+ @ncover = NCoverReport.new
549
+ @ncover.extend(SystemPatch)
550
+ @ncover.log_level = :verbose
551
+
552
+ @ncover.path_to_command = NCoverReportTestData.path_to_command
553
+ @ncover.coverage_files << NCoverReportTestData.coverage_file
554
+
555
+ fullcoveragereport = NCover::FullCoverageReport.new
556
+ fullcoveragereport.output_path = NCoverReportTestData.output_folder
557
+ @ncover.reports << fullcoveragereport
558
+ @ncover.required_coverage << NCover::SymbolCoverage.new(:minimum => 0)
559
+
560
+ @ncover.filters << NCover::DocumentFilter.new(:filter_type => :exclude, :filter => ["Foo"])
561
+ @ncover.filters << NCover::DocumentFilter.new(:filter_type => :include, :filter => ["Bar"])
562
+
563
+ @ncover.run
564
+ end
565
+
566
+ it "should exclude the specified data" do
567
+ $system_command.should include("//cf \"Foo\":Document:false:false")
568
+ end
569
+
570
+ it "should include the specified data" do
571
+ $system_command.should include("//cf \"Bar\":Document:false:true")
572
+ end
573
+
574
+ it "should not fail" do
575
+ @ncover.failed.should be_false
576
+ end
577
+ end