albacore 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/.autotest +4 -4
  2. data/.bundle/config +2 -2
  3. data/.rvmrc +1 -1
  4. data/Gemfile +12 -12
  5. data/README.markdown +92 -68
  6. data/VERSION +1 -1
  7. data/lib/albacore.rb +9 -9
  8. data/lib/albacore/albacoretask.rb +50 -50
  9. data/lib/albacore/aspnetcompiler.rb +58 -58
  10. data/lib/albacore/assemblyinfo.rb +140 -140
  11. data/lib/albacore/assemblyinfolanguages/cppcliengine.rb +17 -0
  12. data/lib/albacore/assemblyinfolanguages/csharpengine.rb +18 -18
  13. data/lib/albacore/assemblyinfolanguages/vbnetengine.rb +18 -18
  14. data/lib/albacore/config/aspnetcompilerconfig.rb +29 -29
  15. data/lib/albacore/config/assemblyinfoconfig.rb +13 -13
  16. data/lib/albacore/config/config.rb +22 -22
  17. data/lib/albacore/config/cscconfig.rb +28 -28
  18. data/lib/albacore/config/docuconfig.rb +23 -23
  19. data/lib/albacore/config/execconfig.rb +15 -15
  20. data/lib/albacore/config/fluentmigratorrunnerconfig.rb +15 -15
  21. data/lib/albacore/config/msbuildconfig.rb +29 -29
  22. data/lib/albacore/config/mspectestrunnerconfig.rb +15 -15
  23. data/lib/albacore/config/mstesttestrunnerconfig.rb +15 -15
  24. data/lib/albacore/config/nantconfig.rb +15 -15
  25. data/lib/albacore/config/nchurnconfig.rb +15 -15
  26. data/lib/albacore/config/ncoverconsoleconfig.rb +15 -15
  27. data/lib/albacore/config/ncoverreportconfig.rb +15 -15
  28. data/lib/albacore/config/ndependconfig.rb +15 -15
  29. data/lib/albacore/config/netversion.rb +21 -21
  30. data/lib/albacore/config/nugetpackconfig.rb +3 -3
  31. data/lib/albacore/config/nugetpublishconfig.rb +19 -0
  32. data/lib/albacore/config/nugetpushconfig.rb +19 -0
  33. data/lib/albacore/config/nunittestrunnerconfig.rb +14 -14
  34. data/lib/albacore/config/specflowreportconfig.rb +24 -24
  35. data/lib/albacore/config/sqlcmdconfig.rb +15 -15
  36. data/lib/albacore/config/unzipconfig.rb +15 -15
  37. data/lib/albacore/config/vssgetconfig.rb +14 -0
  38. data/lib/albacore/config/xbuildconfig.rb +15 -15
  39. data/lib/albacore/config/xunittestrunnerconfig.rb +15 -15
  40. data/lib/albacore/config/zipdirectoryconfig.rb +15 -15
  41. data/lib/albacore/csc.rb +66 -62
  42. data/lib/albacore/docu.rb +41 -41
  43. data/lib/albacore/exec.rb +18 -18
  44. data/lib/albacore/fluentmigratorrunner.rb +51 -46
  45. data/lib/albacore/msbuild.rb +55 -55
  46. data/lib/albacore/mspectestrunner.rb +50 -50
  47. data/lib/albacore/mstesttestrunner.rb +43 -43
  48. data/lib/albacore/nant.rb +38 -38
  49. data/lib/albacore/nchurn.rb +74 -74
  50. data/lib/albacore/ncoverconsole.rb +68 -68
  51. data/lib/albacore/ncoverreport.rb +62 -62
  52. data/lib/albacore/ncoverreports/assemblyfilter.rb +9 -9
  53. data/lib/albacore/ncoverreports/branchcoverage.rb +9 -9
  54. data/lib/albacore/ncoverreports/classfilter.rb +9 -9
  55. data/lib/albacore/ncoverreports/codecoveragebase.rb +25 -25
  56. data/lib/albacore/ncoverreports/cyclomaticcomplexity.rb +23 -23
  57. data/lib/albacore/ncoverreports/documentfilter.rb +9 -9
  58. data/lib/albacore/ncoverreports/fullcoveragereport.rb +13 -13
  59. data/lib/albacore/ncoverreports/methodcoverage.rb +9 -9
  60. data/lib/albacore/ncoverreports/methodfilter.rb +9 -9
  61. data/lib/albacore/ncoverreports/namespacefilter.rb +9 -9
  62. data/lib/albacore/ncoverreports/reportfilterbase.rb +26 -26
  63. data/lib/albacore/ncoverreports/summaryreport.rb +18 -18
  64. data/lib/albacore/ncoverreports/symbolcoverage.rb +9 -9
  65. data/lib/albacore/ndepend.rb +33 -33
  66. data/lib/albacore/nugetpublish.rb +47 -0
  67. data/lib/albacore/nugetpush.rb +46 -0
  68. data/lib/albacore/nunittestrunner.rb +41 -41
  69. data/lib/albacore/nuspec.rb +133 -109
  70. data/lib/albacore/output.rb +99 -99
  71. data/lib/albacore/plink.rb +47 -47
  72. data/lib/albacore/specflowreport.rb +62 -62
  73. data/lib/albacore/sqlcmd.rb +80 -80
  74. data/lib/albacore/support/attrmethods.rb +33 -33
  75. data/lib/albacore/support/createtask.rb +50 -30
  76. data/lib/albacore/support/failure.rb +15 -15
  77. data/lib/albacore/support/logging.rb +38 -38
  78. data/lib/albacore/support/openstruct.rb +13 -13
  79. data/lib/albacore/support/runcommand.rb +45 -45
  80. data/lib/albacore/support/supportlinux.rb +23 -23
  81. data/lib/albacore/support/updateattributes.rb +13 -13
  82. data/lib/albacore/support/yamlconfig.rb +18 -18
  83. data/lib/albacore/unzip.rb +28 -28
  84. data/lib/albacore/vssget.rb +44 -0
  85. data/lib/albacore/xbuild.rb +54 -54
  86. data/lib/albacore/xunittestrunner.rb +52 -52
  87. data/lib/albacore/zipdirectory.rb +105 -105
  88. data/rakefile.rb +297 -297
  89. data/spec/albacoremodel_spec.rb +53 -53
  90. data/spec/assemblyinfo_spec.rb +541 -541
  91. data/spec/attrmethods_spec.rb +136 -136
  92. data/spec/config_spec.rb +34 -34
  93. data/spec/createtask_spec.rb +236 -236
  94. data/spec/csc_spec.rb +253 -253
  95. data/spec/docu_spec.rb +109 -109
  96. data/spec/exec_spec.rb +45 -45
  97. data/spec/fluentmigratorrunner_spec.rb +254 -185
  98. data/spec/msbuild_spec.rb +215 -215
  99. data/spec/mspec_spec.rb +28 -28
  100. data/spec/mstesttestrunner_spec.rb +142 -142
  101. data/spec/nant_spec.rb +110 -110
  102. data/spec/nchurn_spec.rb +75 -75
  103. data/spec/ncoverconsole_spec.rb +353 -353
  104. data/spec/ncoverreport_spec.rb +619 -619
  105. data/spec/ndepend_spec.rb +72 -72
  106. data/spec/nunittestrunner_spec.rb +122 -122
  107. data/spec/nuspec_spec.rb +78 -78
  108. data/spec/patches/docu_patch.rb +12 -12
  109. data/spec/patches/fail_patch.rb +8 -8
  110. data/spec/patches/system_patch.rb +20 -20
  111. data/spec/plink_spec.rb +62 -62
  112. data/spec/runcommand_spec.rb +94 -94
  113. data/spec/spec_helper.rb +17 -17
  114. data/spec/specflowreport_spec.rb +146 -146
  115. data/spec/sqlcmd_spec.rb +334 -334
  116. data/spec/support/assemblyinfotester.rb +51 -51
  117. data/spec/support/ironruby_validator.rb +26 -26
  118. data/spec/support/msbuildtestdata.rb +32 -32
  119. data/spec/support/nanttestdata.rb +33 -33
  120. data/spec/support/ncoverconsoletestdata.rb +19 -19
  121. data/spec/support/ncoverreporttestdata.rb +26 -26
  122. data/spec/support/nokogiri_validator.rb +15 -15
  123. data/spec/support/outputtestdata.rb +12 -12
  124. data/spec/support/ziptestdata.rb +12 -12
  125. data/spec/unzip_spec.rb +15 -15
  126. data/spec/xbuild_spec.rb +15 -15
  127. data/spec/xunit_spec.rb +168 -168
  128. data/spec/yamlconfig_spec.rb +49 -49
  129. data/spec/zip_spec.rb +104 -104
  130. data/watchrtesting.rb +8 -8
  131. metadata +15 -119
@@ -1,75 +1,75 @@
1
- require 'spec_helper'
2
- require 'albacore/nchurn'
3
- require 'patches/system_patch'
4
-
5
- class NChurn
6
- attr_accessor :failure_message
7
-
8
- def fail_with_message(m)
9
- @failure_message = m
10
- end
11
- end
12
-
13
- class NChurnTestData
14
- attr_reader :nchurn_command
15
- attr_reader :output_text
16
- def initialize
17
- @nchurn_command = File.join(File.dirname(__FILE__), 'support', 'Tools', 'NChurn-v0.4', 'nchurn.exe')
18
- @output_text = 'nchurn-test.txt'
19
-
20
- end
21
-
22
- def remove!
23
- FileUtils.rm @output_text if File.exist? @output_text
24
- end
25
- end
26
-
27
- describe NChurn, "when running nchurn" do
28
- before :all do
29
- @nchurn = NChurn.new
30
- @nchurn.extend SystemPatch
31
- @test_data = NChurnTestData.new
32
- @test_data.remove!
33
-
34
- end
35
-
36
- before :each do
37
- @nchurn.failure_message = nil
38
- end
39
-
40
- it "should fail with no command" do
41
- @nchurn.execute
42
- @nchurn.failure_message.should eql('Churn Analysis Failed. See Build Log For Detail.')
43
- end
44
-
45
- it "should succeed and redirect to file" do
46
- @nchurn.command = NChurnTestData.new.nchurn_command
47
- @nchurn.output @test_data.output_text
48
-
49
- @nchurn.execute
50
- @nchurn.failure_message.should be_nil
51
- File.exist?(@test_data.output_text).should be_true
52
- end
53
-
54
- it "should pass all parameters correctly" do
55
- @nchurn.command = "nchurn.exe"
56
- @nchurn.disable_system = true
57
- @nchurn.output @test_data.output_text
58
- @nchurn.input "file.txt"
59
-
60
- @nchurn.churn_precent 30
61
- @nchurn.top 10
62
- @nchurn.report_as :xml
63
- @nchurn.env_path 'c:/tools'
64
- @nchurn.adapter :git
65
- @nchurn.exclude "exe"
66
- @nchurn.include "foo"
67
-
68
- @nchurn.execute
69
- @nchurn.failure_message.should be_nil
70
- cmd = %{"nchurn.exe" -i "file.txt" -c 0.3 -t 10 -r xml -p "c:/tools" -a git -x "exe" -n "foo" > "nchurn-test.txt"}
71
- @nchurn.system_command.should eql(cmd)
72
- end
73
-
74
- end
75
-
1
+ require 'spec_helper'
2
+ require 'albacore/nchurn'
3
+ require 'patches/system_patch'
4
+
5
+ class NChurn
6
+ attr_accessor :failure_message
7
+
8
+ def fail_with_message(m)
9
+ @failure_message = m
10
+ end
11
+ end
12
+
13
+ class NChurnTestData
14
+ attr_reader :nchurn_command
15
+ attr_reader :output_text
16
+ def initialize
17
+ @nchurn_command = File.join(File.dirname(__FILE__), 'support', 'Tools', 'NChurn-v0.4', 'nchurn.exe')
18
+ @output_text = 'nchurn-test.txt'
19
+
20
+ end
21
+
22
+ def remove!
23
+ FileUtils.rm @output_text if File.exist? @output_text
24
+ end
25
+ end
26
+
27
+ describe NChurn, "when running nchurn" do
28
+ before :all do
29
+ @nchurn = NChurn.new
30
+ @nchurn.extend SystemPatch
31
+ @test_data = NChurnTestData.new
32
+ @test_data.remove!
33
+
34
+ end
35
+
36
+ before :each do
37
+ @nchurn.failure_message = nil
38
+ end
39
+
40
+ it "should fail with no command" do
41
+ @nchurn.execute
42
+ @nchurn.failure_message.should eql('Churn Analysis Failed. See Build Log For Detail.')
43
+ end
44
+
45
+ it "should succeed and redirect to file" do
46
+ @nchurn.command = NChurnTestData.new.nchurn_command
47
+ @nchurn.output @test_data.output_text
48
+
49
+ @nchurn.execute
50
+ @nchurn.failure_message.should be_nil
51
+ File.exist?(@test_data.output_text).should be_true
52
+ end
53
+
54
+ it "should pass all parameters correctly" do
55
+ @nchurn.command = "nchurn.exe"
56
+ @nchurn.disable_system = true
57
+ @nchurn.output @test_data.output_text
58
+ @nchurn.input "file.txt"
59
+
60
+ @nchurn.churn_precent 30
61
+ @nchurn.top 10
62
+ @nchurn.report_as :xml
63
+ @nchurn.env_path 'c:/tools'
64
+ @nchurn.adapter :git
65
+ @nchurn.exclude "exe"
66
+ @nchurn.include "foo"
67
+
68
+ @nchurn.execute
69
+ @nchurn.failure_message.should be_nil
70
+ cmd = %{"nchurn.exe" -i "file.txt" -c 0.3 -t 10 -r xml -p "c:/tools" -a git -x "exe" -n "foo" > "nchurn-test.txt"}
71
+ @nchurn.system_command.should eql(cmd)
72
+ end
73
+
74
+ end
75
+
@@ -1,353 +1,353 @@
1
- require 'spec_helper'
2
- require 'albacore/ncoverconsole'
3
- require 'albacore/nunittestrunner'
4
- require 'albacore/mspectestrunner'
5
- require 'ncoverconsoletestdata'
6
-
7
- describe NCoverConsole, "when specifying assemblies to cover" do
8
- before :all do
9
- @testdata = NCoverConsoleTestData.new
10
- File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
11
-
12
- @ncc = NCoverConsole.new()
13
-
14
- @ncc.extend(SystemPatch)
15
- @ncc.log_level = :verbose
16
- @ncc.command = @testdata.ncoverpath
17
- @ncc.output :xml => @testdata.xml_coverage_output
18
- @ncc.working_directory = @testdata.working_directory
19
- @ncc.cover_assemblies "TestSolution"
20
-
21
- nunit = NUnitTestRunner.new(@testdata.nunitpath)
22
- nunit.assemblies @testdata.test_assembly
23
- nunit.options '/noshadow'
24
-
25
- @ncc.testrunner = nunit
26
- @ncc.execute
27
- end
28
-
29
- it "should provide coverage for the specified assemblies" do
30
- @ncc.system_command.should include("//assemblies \"TestSolution\"")
31
- end
32
- end
33
-
34
- describe NCoverConsole, "when specifying assemblies with spaces in the name" do
35
- before :all do
36
- @testdata = NCoverConsoleTestData.new
37
- File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
38
-
39
- @ncc = NCoverConsole.new()
40
-
41
- @ncc.extend(SystemPatch)
42
- @ncc.log_level = :verbose
43
- @ncc.command = @testdata.ncoverpath
44
- @ncc.output :xml => @testdata.xml_coverage_output
45
- @ncc.working_directory = @testdata.working_directory
46
- @ncc.cover_assemblies "assemblies/with spaces/TestSolution"
47
-
48
- nunit = NUnitTestRunner.new(@testdata.nunitpath)
49
- nunit.assemblies @testdata.test_assembly_with_spaces
50
- nunit.options '/noshadow'
51
-
52
- @ncc.testrunner = nunit
53
- @ncc.execute
54
- end
55
-
56
- it "should provide coverage for the specified assemblies" do
57
- @ncc.system_command.should include("//assemblies \"assemblies/with spaces/TestSolution\"")
58
- end
59
-
60
- end
61
-
62
- describe NCoverConsole, "when specifying assemblies to ignore" do
63
- before :all do
64
- @testdata = NCoverConsoleTestData.new
65
- File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
66
-
67
- @ncc = NCoverConsole.new()
68
-
69
- @ncc.extend(SystemPatch)
70
- @ncc.log_level = :verbose
71
- @ncc.command = @testdata.ncoverpath
72
- @ncc.output :xml => @testdata.xml_coverage_output
73
- @ncc.working_directory = @testdata.working_directory
74
- @ncc.exclude_assemblies "TestSolution.*"
75
-
76
- nunit = NUnitTestRunner.new(@testdata.nunitpath)
77
- nunit.assemblies @testdata.test_assembly
78
- nunit.options '/noshadow'
79
-
80
- @ncc.testrunner = nunit
81
- @ncc.execute
82
- end
83
-
84
- it "should provide coverage for the specified assemblies" do
85
- @ncc.system_command.should include("//exclude-assemblies \"TestSolution.*\"")
86
- end
87
- end
88
-
89
- describe NCoverConsole, "when specifying attributes to exclude" do
90
- before :all do
91
- @testdata = NCoverConsoleTestData.new
92
- File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
93
-
94
- @ncc = NCoverConsole.new()
95
-
96
- @ncc.extend(SystemPatch)
97
- @ncc.log_level = :verbose
98
- @ncc.command = @testdata.ncoverpath
99
- @ncc.output :xml => @testdata.xml_coverage_output
100
- @ncc.working_directory = @testdata.working_directory
101
- @ncc.exclude_attributes "excludeme", "excludeme_too"
102
-
103
- nunit = NUnitTestRunner.new(@testdata.nunitpath)
104
- nunit.assemblies @testdata.test_assembly
105
- nunit.options '/noshadow'
106
-
107
- @ncc.testrunner = nunit
108
- @ncc.execute
109
- end
110
-
111
- it "should not provide coverage for the excluded attributes" do
112
- @ncc.system_command.should include("//exclude-attributes \"excludeme\";\"excludeme_too\"")
113
- end
114
- end
115
-
116
- describe NCoverConsole, "when running with the defaults" do
117
- before :all do
118
- @testdata = NCoverConsoleTestData.new
119
- @ncc = NCoverConsole.new
120
-
121
- @ncc.extend(SystemPatch)
122
- @ncc.extend(FailPatch)
123
-
124
- @ncc.command = @testdata.ncoverpath
125
- @ncc.testrunner = NUnitTestRunner.new
126
-
127
- @ncc.execute
128
- end
129
-
130
- it "should include the register flag in the command" do
131
- @ncc.system_command.should include("//reg")
132
- end
133
- end
134
-
135
- describe NCoverConsole, "when opting out of registering the ncover dll" do
136
- before :all do
137
- @testdata = NCoverConsoleTestData.new
138
- @ncc = NCoverConsole.new
139
-
140
- @ncc.extend(SystemPatch)
141
- @ncc.extend(FailPatch)
142
-
143
- @ncc.command = @testdata.ncoverpath
144
- @ncc.no_registration
145
- @ncc.testrunner = NUnitTestRunner.new
146
-
147
- @ncc.execute
148
- end
149
-
150
- it "should not include the register flag in the command" do
151
- @ncc.system_command.should_not include("//reg")
152
- end
153
- end
154
-
155
- describe NCoverConsole, "when specifying the types of coverage to analyze" do
156
- before :all do
157
- @testdata = NCoverConsoleTestData.new
158
- File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
159
-
160
- @ncc = NCoverConsole.new()
161
-
162
- @ncc.extend(SystemPatch)
163
- @ncc.log_level = :verbose
164
- @ncc.command = @testdata.ncoverpath
165
- @ncc.output :xml => @testdata.xml_coverage_output
166
- @ncc.working_directory = @testdata.working_directory
167
- @ncc.coverage :Symbol, :Branch, :MethodVisits, :CyclomaticComplexity
168
-
169
- nunit = NUnitTestRunner.new(@testdata.nunitpath)
170
- nunit.assemblies @testdata.test_assembly
171
- nunit.options '/noshadow'
172
-
173
- @ncc.testrunner = nunit
174
- @ncc.execute
175
- end
176
-
177
- it "should only run coverage for those metrics" do
178
- @ncc.system_command.should include("//coverage-type \"Symbol, Branch, MethodVisits, CyclomaticComplexity\"")
179
- end
180
- end
181
-
182
- describe NCoverConsole, "when analyzing a test suite with failing tests" do
183
- before :all do
184
- @testdata = NCoverConsoleTestData.new
185
- File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
186
-
187
- ncc = NCoverConsole.new()
188
- strio = StringIO.new
189
- ncc.log_device = strio
190
-
191
- ncc.extend(SystemPatch)
192
- ncc.extend(FailPatch)
193
-
194
- ncc.log_level = :verbose
195
- ncc.command = @testdata.ncoverpath
196
- ncc.output :xml => @testdata.xml_coverage_output
197
- ncc.working_directory = @testdata.working_directory
198
-
199
- nunit = NUnitTestRunner.new(@testdata.nunitpath)
200
- nunit.assemblies @testdata.failing_test_assembly
201
- nunit.options '/noshadow'
202
-
203
- ncc.testrunner = nunit
204
-
205
- ncc.execute
206
- @log_data = strio.string
207
- end
208
-
209
- it "should return a failure code" do
210
- $task_failed.should == true
211
- end
212
-
213
- it "should log a failure message" do
214
- @log_data.should include("Code Coverage Analysis Failed. See Build Log For Detail.")
215
- end
216
- end
217
-
218
- describe NCoverConsole, "when running without a testrunner" do
219
- before :all do
220
- @testdata = NCoverConsoleTestData.new
221
- ncc = NCoverConsole.new()
222
- ncc.extend(FailPatch)
223
- strio = StringIO.new
224
- ncc.log_device = strio
225
-
226
- ncc.execute
227
- @log_data = strio.string
228
- end
229
-
230
- it "should log a message saying the test runner is required" do
231
- @log_data.should include("testrunner cannot be nil.")
232
- end
233
-
234
- it "should fail the task" do
235
- $task_failed.should be_true
236
- end
237
- end
238
-
239
- describe NCoverConsole, "when producing an xml coverage report with nunit" do
240
- before :all do
241
- @testdata = NCoverConsoleTestData.new
242
- File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
243
-
244
- @ncc = NCoverConsole.new()
245
-
246
- @ncc.extend(SystemPatch)
247
- @ncc.log_level = :verbose
248
- @ncc.command = @testdata.ncoverpath
249
- @ncc.output :xml => @testdata.xml_coverage_output
250
- @ncc.working_directory = @testdata.working_directory
251
-
252
- nunit = NUnitTestRunner.new(@testdata.nunitpath)
253
- nunit.assemblies @testdata.test_assembly
254
- nunit.options '/noshadow'
255
-
256
- @ncc.testrunner = nunit
257
- @ncc.execute
258
- end
259
-
260
- it "should execute ncover.console from the specified path" do
261
- @ncc.system_command.should include(File.expand_path(@testdata.ncoverpath))
262
- end
263
-
264
- it "should execute the test runner from the specified path" do
265
- @ncc.system_command.downcase.should include(@testdata.nunitpath.downcase)
266
- end
267
-
268
- it "should pass the specified assembly to the test runner" do
269
- @ncc.system_command.should include("TestSolution.Tests.dll")
270
- end
271
-
272
- it "should tell nunit to use the noshadow option" do
273
- @ncc.system_command.should include("/noshadow")
274
- end
275
-
276
- it "should write the coverage data to the specified file" do
277
- File.exist?(@testdata.xml_coverage_output).should == true
278
- end
279
- end
280
-
281
- describe NCoverConsole, "when specifying an html report and an xml coverage report with nunit" do
282
- before :all do
283
- @testdata = NCoverConsoleTestData.new
284
- File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
285
- File.delete(@testdata.html_coverage_output) if File.exist?(@testdata.html_coverage_output)
286
-
287
- ncc = NCoverConsole.new()
288
-
289
- ncc.extend(SystemPatch)
290
- ncc.log_level = :verbose
291
- ncc.command = @testdata.ncoverpath
292
- ncc.output :xml => @testdata.xml_coverage_output, :html => @testdata.html_coverage_output
293
- ncc.working_directory = @testdata.working_directory
294
-
295
- nunit = NUnitTestRunner.new(@testdata.nunitpath)
296
- nunit.assemblies @testdata.test_assembly
297
- nunit.options '/noshadow'
298
-
299
- ncc.testrunner = nunit
300
- ncc.execute
301
- end
302
-
303
- it "should produce the xml report" do
304
- File.exist?(@testdata.xml_coverage_output).should == true
305
- end
306
-
307
- it "should produce the html report" do
308
- File.exist?(@testdata.html_coverage_output).should == true
309
- end
310
- end
311
-
312
- describe NCoverConsole, "when producing a report with machine.specifications" do
313
- before :all do
314
- @testdata = NCoverConsoleTestData.new
315
- @ncc = NCoverConsole.new()
316
-
317
- @ncc.extend(SystemPatch)
318
- @ncc.extend(FailPatch)
319
-
320
- @ncc.log_level = :verbose
321
- @ncc.command = @testdata.ncoverpath
322
- @ncc.output :xml => @testdata.xml_coverage_output
323
- @ncc.working_directory = @testdata.working_directory
324
-
325
- mspec = MSpecTestRunner.new(@testdata.mspecpath)
326
- mspec.assemblies @testdata.mspec_test_assembly
327
- mspec.html_output = @testdata.mspec_html_output
328
-
329
- @ncc.testrunner = mspec
330
- @ncc.execute
331
- end
332
-
333
- it "should not fail" do
334
- $task_failed.should be_false
335
- end
336
-
337
- it "should produce the html report" do
338
- File.exist?(@testdata.mspec_html_output.to_s).should be_true
339
- end
340
- end
341
-
342
- describe NCoverConsole, "when providing configuration" do
343
- let :ncoverconsole do
344
- Albacore.configure do |config|
345
- config.ncoverconsole.command = "configured"
346
- end
347
- ncoverconsole = NCoverConsole.new
348
- end
349
-
350
- it "should use the configuration values" do
351
- ncoverconsole.command.should == "configured"
352
- end
353
- end
1
+ require 'spec_helper'
2
+ require 'albacore/ncoverconsole'
3
+ require 'albacore/nunittestrunner'
4
+ require 'albacore/mspectestrunner'
5
+ require 'ncoverconsoletestdata'
6
+
7
+ describe NCoverConsole, "when specifying assemblies to cover" do
8
+ before :all do
9
+ @testdata = NCoverConsoleTestData.new
10
+ File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
11
+
12
+ @ncc = NCoverConsole.new()
13
+
14
+ @ncc.extend(SystemPatch)
15
+ @ncc.log_level = :verbose
16
+ @ncc.command = @testdata.ncoverpath
17
+ @ncc.output :xml => @testdata.xml_coverage_output
18
+ @ncc.working_directory = @testdata.working_directory
19
+ @ncc.cover_assemblies "TestSolution"
20
+
21
+ nunit = NUnitTestRunner.new(@testdata.nunitpath)
22
+ nunit.assemblies @testdata.test_assembly
23
+ nunit.options '/noshadow'
24
+
25
+ @ncc.testrunner = nunit
26
+ @ncc.execute
27
+ end
28
+
29
+ it "should provide coverage for the specified assemblies" do
30
+ @ncc.system_command.should include("//assemblies \"TestSolution\"")
31
+ end
32
+ end
33
+
34
+ describe NCoverConsole, "when specifying assemblies with spaces in the name" do
35
+ before :all do
36
+ @testdata = NCoverConsoleTestData.new
37
+ File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
38
+
39
+ @ncc = NCoverConsole.new()
40
+
41
+ @ncc.extend(SystemPatch)
42
+ @ncc.log_level = :verbose
43
+ @ncc.command = @testdata.ncoverpath
44
+ @ncc.output :xml => @testdata.xml_coverage_output
45
+ @ncc.working_directory = @testdata.working_directory
46
+ @ncc.cover_assemblies "assemblies/with spaces/TestSolution"
47
+
48
+ nunit = NUnitTestRunner.new(@testdata.nunitpath)
49
+ nunit.assemblies @testdata.test_assembly_with_spaces
50
+ nunit.options '/noshadow'
51
+
52
+ @ncc.testrunner = nunit
53
+ @ncc.execute
54
+ end
55
+
56
+ it "should provide coverage for the specified assemblies" do
57
+ @ncc.system_command.should include("//assemblies \"assemblies/with spaces/TestSolution\"")
58
+ end
59
+
60
+ end
61
+
62
+ describe NCoverConsole, "when specifying assemblies to ignore" do
63
+ before :all do
64
+ @testdata = NCoverConsoleTestData.new
65
+ File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
66
+
67
+ @ncc = NCoverConsole.new()
68
+
69
+ @ncc.extend(SystemPatch)
70
+ @ncc.log_level = :verbose
71
+ @ncc.command = @testdata.ncoverpath
72
+ @ncc.output :xml => @testdata.xml_coverage_output
73
+ @ncc.working_directory = @testdata.working_directory
74
+ @ncc.exclude_assemblies "TestSolution.*"
75
+
76
+ nunit = NUnitTestRunner.new(@testdata.nunitpath)
77
+ nunit.assemblies @testdata.test_assembly
78
+ nunit.options '/noshadow'
79
+
80
+ @ncc.testrunner = nunit
81
+ @ncc.execute
82
+ end
83
+
84
+ it "should provide coverage for the specified assemblies" do
85
+ @ncc.system_command.should include("//exclude-assemblies \"TestSolution.*\"")
86
+ end
87
+ end
88
+
89
+ describe NCoverConsole, "when specifying attributes to exclude" do
90
+ before :all do
91
+ @testdata = NCoverConsoleTestData.new
92
+ File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
93
+
94
+ @ncc = NCoverConsole.new()
95
+
96
+ @ncc.extend(SystemPatch)
97
+ @ncc.log_level = :verbose
98
+ @ncc.command = @testdata.ncoverpath
99
+ @ncc.output :xml => @testdata.xml_coverage_output
100
+ @ncc.working_directory = @testdata.working_directory
101
+ @ncc.exclude_attributes "excludeme", "excludeme_too"
102
+
103
+ nunit = NUnitTestRunner.new(@testdata.nunitpath)
104
+ nunit.assemblies @testdata.test_assembly
105
+ nunit.options '/noshadow'
106
+
107
+ @ncc.testrunner = nunit
108
+ @ncc.execute
109
+ end
110
+
111
+ it "should not provide coverage for the excluded attributes" do
112
+ @ncc.system_command.should include("//exclude-attributes \"excludeme\";\"excludeme_too\"")
113
+ end
114
+ end
115
+
116
+ describe NCoverConsole, "when running with the defaults" do
117
+ before :all do
118
+ @testdata = NCoverConsoleTestData.new
119
+ @ncc = NCoverConsole.new
120
+
121
+ @ncc.extend(SystemPatch)
122
+ @ncc.extend(FailPatch)
123
+
124
+ @ncc.command = @testdata.ncoverpath
125
+ @ncc.testrunner = NUnitTestRunner.new
126
+
127
+ @ncc.execute
128
+ end
129
+
130
+ it "should include the register flag in the command" do
131
+ @ncc.system_command.should include("//reg")
132
+ end
133
+ end
134
+
135
+ describe NCoverConsole, "when opting out of registering the ncover dll" do
136
+ before :all do
137
+ @testdata = NCoverConsoleTestData.new
138
+ @ncc = NCoverConsole.new
139
+
140
+ @ncc.extend(SystemPatch)
141
+ @ncc.extend(FailPatch)
142
+
143
+ @ncc.command = @testdata.ncoverpath
144
+ @ncc.no_registration
145
+ @ncc.testrunner = NUnitTestRunner.new
146
+
147
+ @ncc.execute
148
+ end
149
+
150
+ it "should not include the register flag in the command" do
151
+ @ncc.system_command.should_not include("//reg")
152
+ end
153
+ end
154
+
155
+ describe NCoverConsole, "when specifying the types of coverage to analyze" do
156
+ before :all do
157
+ @testdata = NCoverConsoleTestData.new
158
+ File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
159
+
160
+ @ncc = NCoverConsole.new()
161
+
162
+ @ncc.extend(SystemPatch)
163
+ @ncc.log_level = :verbose
164
+ @ncc.command = @testdata.ncoverpath
165
+ @ncc.output :xml => @testdata.xml_coverage_output
166
+ @ncc.working_directory = @testdata.working_directory
167
+ @ncc.coverage :Symbol, :Branch, :MethodVisits, :CyclomaticComplexity
168
+
169
+ nunit = NUnitTestRunner.new(@testdata.nunitpath)
170
+ nunit.assemblies @testdata.test_assembly
171
+ nunit.options '/noshadow'
172
+
173
+ @ncc.testrunner = nunit
174
+ @ncc.execute
175
+ end
176
+
177
+ it "should only run coverage for those metrics" do
178
+ @ncc.system_command.should include("//coverage-type \"Symbol, Branch, MethodVisits, CyclomaticComplexity\"")
179
+ end
180
+ end
181
+
182
+ describe NCoverConsole, "when analyzing a test suite with failing tests" do
183
+ before :all do
184
+ @testdata = NCoverConsoleTestData.new
185
+ File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
186
+
187
+ ncc = NCoverConsole.new()
188
+ strio = StringIO.new
189
+ ncc.log_device = strio
190
+
191
+ ncc.extend(SystemPatch)
192
+ ncc.extend(FailPatch)
193
+
194
+ ncc.log_level = :verbose
195
+ ncc.command = @testdata.ncoverpath
196
+ ncc.output :xml => @testdata.xml_coverage_output
197
+ ncc.working_directory = @testdata.working_directory
198
+
199
+ nunit = NUnitTestRunner.new(@testdata.nunitpath)
200
+ nunit.assemblies @testdata.failing_test_assembly
201
+ nunit.options '/noshadow'
202
+
203
+ ncc.testrunner = nunit
204
+
205
+ ncc.execute
206
+ @log_data = strio.string
207
+ end
208
+
209
+ it "should return a failure code" do
210
+ $task_failed.should == true
211
+ end
212
+
213
+ it "should log a failure message" do
214
+ @log_data.should include("Code Coverage Analysis Failed. See Build Log For Detail.")
215
+ end
216
+ end
217
+
218
+ describe NCoverConsole, "when running without a testrunner" do
219
+ before :all do
220
+ @testdata = NCoverConsoleTestData.new
221
+ ncc = NCoverConsole.new()
222
+ ncc.extend(FailPatch)
223
+ strio = StringIO.new
224
+ ncc.log_device = strio
225
+
226
+ ncc.execute
227
+ @log_data = strio.string
228
+ end
229
+
230
+ it "should log a message saying the test runner is required" do
231
+ @log_data.should include("testrunner cannot be nil.")
232
+ end
233
+
234
+ it "should fail the task" do
235
+ $task_failed.should be_true
236
+ end
237
+ end
238
+
239
+ describe NCoverConsole, "when producing an xml coverage report with nunit" do
240
+ before :all do
241
+ @testdata = NCoverConsoleTestData.new
242
+ File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
243
+
244
+ @ncc = NCoverConsole.new()
245
+
246
+ @ncc.extend(SystemPatch)
247
+ @ncc.log_level = :verbose
248
+ @ncc.command = @testdata.ncoverpath
249
+ @ncc.output :xml => @testdata.xml_coverage_output
250
+ @ncc.working_directory = @testdata.working_directory
251
+
252
+ nunit = NUnitTestRunner.new(@testdata.nunitpath)
253
+ nunit.assemblies @testdata.test_assembly
254
+ nunit.options '/noshadow'
255
+
256
+ @ncc.testrunner = nunit
257
+ @ncc.execute
258
+ end
259
+
260
+ it "should execute ncover.console from the specified path" do
261
+ @ncc.system_command.should include(File.expand_path(@testdata.ncoverpath))
262
+ end
263
+
264
+ it "should execute the test runner from the specified path" do
265
+ @ncc.system_command.downcase.should include(@testdata.nunitpath.downcase)
266
+ end
267
+
268
+ it "should pass the specified assembly to the test runner" do
269
+ @ncc.system_command.should include("TestSolution.Tests.dll")
270
+ end
271
+
272
+ it "should tell nunit to use the noshadow option" do
273
+ @ncc.system_command.should include("/noshadow")
274
+ end
275
+
276
+ it "should write the coverage data to the specified file" do
277
+ File.exist?(@testdata.xml_coverage_output).should == true
278
+ end
279
+ end
280
+
281
+ describe NCoverConsole, "when specifying an html report and an xml coverage report with nunit" do
282
+ before :all do
283
+ @testdata = NCoverConsoleTestData.new
284
+ File.delete(@testdata.xml_coverage_output) if File.exist?(@testdata.xml_coverage_output)
285
+ File.delete(@testdata.html_coverage_output) if File.exist?(@testdata.html_coverage_output)
286
+
287
+ ncc = NCoverConsole.new()
288
+
289
+ ncc.extend(SystemPatch)
290
+ ncc.log_level = :verbose
291
+ ncc.command = @testdata.ncoverpath
292
+ ncc.output :xml => @testdata.xml_coverage_output, :html => @testdata.html_coverage_output
293
+ ncc.working_directory = @testdata.working_directory
294
+
295
+ nunit = NUnitTestRunner.new(@testdata.nunitpath)
296
+ nunit.assemblies @testdata.test_assembly
297
+ nunit.options '/noshadow'
298
+
299
+ ncc.testrunner = nunit
300
+ ncc.execute
301
+ end
302
+
303
+ it "should produce the xml report" do
304
+ File.exist?(@testdata.xml_coverage_output).should == true
305
+ end
306
+
307
+ it "should produce the html report" do
308
+ File.exist?(@testdata.html_coverage_output).should == true
309
+ end
310
+ end
311
+
312
+ describe NCoverConsole, "when producing a report with machine.specifications" do
313
+ before :all do
314
+ @testdata = NCoverConsoleTestData.new
315
+ @ncc = NCoverConsole.new()
316
+
317
+ @ncc.extend(SystemPatch)
318
+ @ncc.extend(FailPatch)
319
+
320
+ @ncc.log_level = :verbose
321
+ @ncc.command = @testdata.ncoverpath
322
+ @ncc.output :xml => @testdata.xml_coverage_output
323
+ @ncc.working_directory = @testdata.working_directory
324
+
325
+ mspec = MSpecTestRunner.new(@testdata.mspecpath)
326
+ mspec.assemblies @testdata.mspec_test_assembly
327
+ mspec.html_output = @testdata.mspec_html_output
328
+
329
+ @ncc.testrunner = mspec
330
+ @ncc.execute
331
+ end
332
+
333
+ it "should not fail" do
334
+ $task_failed.should be_false
335
+ end
336
+
337
+ it "should produce the html report" do
338
+ File.exist?(@testdata.mspec_html_output.to_s).should be_true
339
+ end
340
+ end
341
+
342
+ describe NCoverConsole, "when providing configuration" do
343
+ let :ncoverconsole do
344
+ Albacore.configure do |config|
345
+ config.ncoverconsole.command = "configured"
346
+ end
347
+ ncoverconsole = NCoverConsole.new
348
+ end
349
+
350
+ it "should use the configuration values" do
351
+ ncoverconsole.command.should == "configured"
352
+ end
353
+ end