buildr 1.2.10 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/CHANGELOG +566 -268
  2. data/DISCLAIMER +7 -1
  3. data/KEYS +151 -0
  4. data/NOTICE +23 -8
  5. data/README +122 -22
  6. data/Rakefile +49 -229
  7. data/{lib → addon}/buildr/antlr.rb +23 -10
  8. data/addon/buildr/cobertura.rb +232 -0
  9. data/{lib → addon}/buildr/hibernate.rb +20 -4
  10. data/{lib → addon}/buildr/javacc.rb +27 -12
  11. data/addon/buildr/jdepend.rb +60 -0
  12. data/{lib → addon}/buildr/jetty.rb +34 -18
  13. data/addon/buildr/nailgun.rb +892 -0
  14. data/{lib → addon}/buildr/openjpa.rb +23 -6
  15. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  16. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  17. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  18. data/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
  19. data/{lib → addon}/buildr/xmlbeans.rb +39 -14
  20. data/bin/buildr +21 -7
  21. data/buildr.gemspec +50 -0
  22. data/doc/css/default.css +225 -0
  23. data/doc/css/print.css +95 -0
  24. data/doc/css/syntax.css +43 -0
  25. data/doc/images/apache-incubator-logo.png +0 -0
  26. data/doc/images/buildr-hires.png +0 -0
  27. data/doc/images/buildr.png +0 -0
  28. data/doc/images/note.png +0 -0
  29. data/doc/images/tip.png +0 -0
  30. data/doc/images/zbuildr.tif +0 -0
  31. data/doc/pages/artifacts.textile +317 -0
  32. data/doc/pages/building.textile +501 -0
  33. data/doc/pages/contributing.textile +178 -0
  34. data/doc/pages/download.textile +25 -0
  35. data/doc/pages/extending.textile +229 -0
  36. data/doc/pages/getting_started.textile +337 -0
  37. data/doc/pages/index.textile +63 -0
  38. data/doc/pages/mailing_lists.textile +17 -0
  39. data/doc/pages/more_stuff.textile +367 -0
  40. data/doc/pages/packaging.textile +592 -0
  41. data/doc/pages/projects.textile +449 -0
  42. data/doc/pages/recipes.textile +127 -0
  43. data/doc/pages/settings_profiles.textile +339 -0
  44. data/doc/pages/testing.textile +475 -0
  45. data/doc/pages/troubleshooting.textile +121 -0
  46. data/doc/pages/whats_new.textile +389 -0
  47. data/doc/print.haml +52 -0
  48. data/doc/print.toc.yaml +28 -0
  49. data/doc/scripts/buildr-git.rb +411 -0
  50. data/doc/scripts/install-jruby.sh +44 -0
  51. data/doc/scripts/install-linux.sh +64 -0
  52. data/doc/scripts/install-osx.sh +52 -0
  53. data/doc/site.haml +55 -0
  54. data/doc/site.toc.yaml +44 -0
  55. data/lib/buildr.rb +28 -45
  56. data/lib/buildr/core.rb +27 -0
  57. data/lib/buildr/core/application.rb +373 -0
  58. data/lib/buildr/core/application_cli.rb +134 -0
  59. data/lib/{core → buildr/core}/build.rb +91 -77
  60. data/lib/{core → buildr/core}/checks.rb +116 -95
  61. data/lib/buildr/core/common.rb +155 -0
  62. data/lib/buildr/core/compile.rb +594 -0
  63. data/lib/buildr/core/environment.rb +120 -0
  64. data/lib/buildr/core/filter.rb +258 -0
  65. data/lib/{core → buildr/core}/generate.rb +22 -5
  66. data/lib/buildr/core/help.rb +118 -0
  67. data/lib/buildr/core/progressbar.rb +156 -0
  68. data/lib/{core → buildr/core}/project.rb +468 -213
  69. data/lib/buildr/core/test.rb +690 -0
  70. data/lib/{core → buildr/core}/transports.rb +107 -127
  71. data/lib/buildr/core/util.rb +235 -0
  72. data/lib/buildr/ide.rb +19 -0
  73. data/lib/{java → buildr/ide}/eclipse.rb +86 -60
  74. data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
  75. data/lib/buildr/ide/idea.rb +194 -0
  76. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  77. data/lib/buildr/ide/idea7x.rb +210 -0
  78. data/lib/buildr/java.rb +26 -0
  79. data/lib/buildr/java/ant.rb +71 -0
  80. data/lib/buildr/java/bdd_frameworks.rb +267 -0
  81. data/lib/buildr/java/commands.rb +210 -0
  82. data/lib/buildr/java/compilers.rb +432 -0
  83. data/lib/buildr/java/deprecated.rb +141 -0
  84. data/lib/buildr/java/groovyc.rb +137 -0
  85. data/lib/buildr/java/jruby.rb +99 -0
  86. data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
  87. data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
  88. data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
  89. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  90. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
  91. data/lib/buildr/java/packaging.rb +706 -0
  92. data/lib/{java → buildr/java}/pom.rb +20 -4
  93. data/lib/buildr/java/rjb.rb +142 -0
  94. data/lib/buildr/java/test_frameworks.rb +290 -0
  95. data/lib/buildr/java/version_requirement.rb +172 -0
  96. data/lib/buildr/packaging.rb +21 -0
  97. data/lib/{java → buildr/packaging}/artifact.rb +170 -179
  98. data/lib/buildr/packaging/artifact_namespace.rb +957 -0
  99. data/lib/buildr/packaging/artifact_search.rb +140 -0
  100. data/lib/buildr/packaging/gems.rb +102 -0
  101. data/lib/buildr/packaging/package.rb +233 -0
  102. data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
  103. data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
  104. data/rakelib/apache.rake +126 -0
  105. data/rakelib/changelog.rake +56 -0
  106. data/rakelib/doc.rake +103 -0
  107. data/rakelib/package.rake +44 -0
  108. data/rakelib/release.rake +53 -0
  109. data/rakelib/rspec.rake +81 -0
  110. data/rakelib/rubyforge.rake +45 -0
  111. data/rakelib/scm.rake +49 -0
  112. data/rakelib/setup.rake +59 -0
  113. data/rakelib/stage.rake +45 -0
  114. data/spec/application_spec.rb +316 -0
  115. data/spec/archive_spec.rb +494 -0
  116. data/spec/artifact_namespace_spec.rb +635 -0
  117. data/spec/artifact_spec.rb +738 -0
  118. data/spec/build_spec.rb +193 -0
  119. data/spec/checks_spec.rb +537 -0
  120. data/spec/common_spec.rb +579 -0
  121. data/spec/compile_spec.rb +561 -0
  122. data/spec/groovy_compilers_spec.rb +239 -0
  123. data/spec/java_bdd_frameworks_spec.rb +238 -0
  124. data/spec/java_compilers_spec.rb +446 -0
  125. data/spec/java_packaging_spec.rb +1042 -0
  126. data/spec/java_test_frameworks_spec.rb +414 -0
  127. data/spec/packaging_helper.rb +63 -0
  128. data/spec/packaging_spec.rb +589 -0
  129. data/spec/project_spec.rb +739 -0
  130. data/spec/sandbox.rb +116 -0
  131. data/spec/scala_compilers_spec.rb +239 -0
  132. data/spec/spec.opts +6 -0
  133. data/spec/spec_helpers.rb +283 -0
  134. data/spec/test_spec.rb +871 -0
  135. data/spec/transport_spec.rb +300 -0
  136. data/spec/version_requirement_spec.rb +115 -0
  137. metadata +188 -77
  138. data/lib/buildr/cobertura.rb +0 -89
  139. data/lib/buildr/jdepend.rb +0 -40
  140. data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
  141. data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
  142. data/lib/buildr/jetty/JettyWrapper.class +0 -0
  143. data/lib/buildr/scala.rb +0 -368
  144. data/lib/core/application.rb +0 -188
  145. data/lib/core/common.rb +0 -562
  146. data/lib/core/help.rb +0 -72
  147. data/lib/core/rake_ext.rb +0 -81
  148. data/lib/java/ant.rb +0 -71
  149. data/lib/java/compile.rb +0 -589
  150. data/lib/java/idea.rb +0 -159
  151. data/lib/java/java.rb +0 -432
  152. data/lib/java/packaging.rb +0 -581
  153. data/lib/java/test.rb +0 -795
  154. data/lib/tasks/concat.rb +0 -35
@@ -0,0 +1,414 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require File.join(File.dirname(__FILE__), 'spec_helpers')
18
+
19
+
20
+ describe Buildr::JUnit do
21
+ it 'should be the default test framework when test cases are in java' do
22
+ write 'src/test/java/com/exampe/FirstTest.java', <<-JAVA
23
+ package com.example;
24
+ public class FirstTest extends junit.framework.TestCase { }
25
+ JAVA
26
+ define 'foo'
27
+ project('foo').test.framework.should eql(:junit)
28
+ end
29
+
30
+ it 'should be picked if the test language is Java' do
31
+ define 'foo' do
32
+ test.compile.using(:javac)
33
+ test.framework.should eql(:junit)
34
+ end
35
+ end
36
+
37
+ it 'should include JUnit dependencies' do
38
+ define('foo') { test.using(:junit) }
39
+ project('foo').test.compile.dependencies.should include(*artifacts(JUnit::REQUIRES))
40
+ project('foo').test.dependencies.should include(*artifacts(JUnit::REQUIRES))
41
+ end
42
+
43
+ it 'should include JMock dependencies' do
44
+ define('foo') { test.using(:junit) }
45
+ project('foo').test.compile.dependencies.should include(*artifacts(JMock::REQUIRES))
46
+ project('foo').test.dependencies.should include(*artifacts(JMock::REQUIRES))
47
+ end
48
+
49
+ it 'should include public classes extending junit.framework.TestCase' do
50
+ write 'src/test/java/com/example/FirstTest.java', <<-JAVA
51
+ package com.example;
52
+ public class FirstTest extends junit.framework.TestCase {
53
+ public void testNothing() { }
54
+ }
55
+ JAVA
56
+ write 'src/test/java/com/example/AnotherOne.java', <<-JAVA
57
+ package com.example;
58
+ public class AnotherOne extends junit.framework.TestCase {
59
+ public void testNothing() { }
60
+ }
61
+ JAVA
62
+ define('foo').test.invoke
63
+ project('foo').test.tests.should include('com.example.FirstTest', 'com.example.AnotherOne')
64
+ end
65
+
66
+ it 'should include public classes with annotated test cases' do
67
+ write 'src/test/java/com/example/FirstTest.java', <<-JAVA
68
+ package com.example;
69
+ import org.junit.Test;
70
+ public class FirstTest {
71
+ public void utilityMethod() { }
72
+ @Test
73
+ public void annotated() { }
74
+ }
75
+ JAVA
76
+ define('foo').test.invoke
77
+ project('foo').test.tests.should include('com.example.FirstTest')
78
+ end
79
+
80
+ it 'should include public classes with RunWith annotation' do
81
+ write 'src/test/java/com/example/TestSuite.java', <<-JAVA
82
+ package com.example;
83
+ import org.junit.Test;
84
+ public class TestSuite {
85
+ @Test
86
+ public void annotated() { }
87
+ }
88
+ JAVA
89
+ write 'src/test/java/com/example/RunSuite.java', <<-JAVA
90
+ package com.example;
91
+ import org.junit.runner.RunWith;
92
+ import org.junit.runners.Suite;
93
+ @RunWith(Suite.class)
94
+ @Suite.SuiteClasses({TestSuite.class})
95
+ public class RunSuite {
96
+ }
97
+ JAVA
98
+ define('foo').test.invoke
99
+ project('foo').test.tests.should include('com.example.RunSuite')
100
+ end
101
+
102
+ it 'should ignore classes not extending junit.framework.TestCase' do
103
+ write 'src/test/java/NotATest.java', <<-JAVA
104
+ public class NotATest { }
105
+ JAVA
106
+ define('foo').test.invoke
107
+ project('foo').test.tests.should be_empty
108
+ end
109
+
110
+ it 'should ignore inner classes' do
111
+ write 'src/test/java/InnerClassTest.java', <<-JAVA
112
+ public class InnerClassTest extends junit.framework.TestCase {
113
+ public void testNothing() { }
114
+
115
+ public class InnerTest extends junit.framework.TestCase {
116
+ public void testNothing() { }
117
+ }
118
+ }
119
+ JAVA
120
+ define('foo').test.invoke
121
+ project('foo').test.tests.should eql(['InnerClassTest'])
122
+ end
123
+
124
+ it 'should pass when JUnit test case passes' do
125
+ write 'src/test/java/PassingTest.java', <<-JAVA
126
+ public class PassingTest extends junit.framework.TestCase {
127
+ public void testNothing() {}
128
+ }
129
+ JAVA
130
+ lambda { define('foo').test.invoke }.should_not raise_error
131
+ end
132
+
133
+ it 'should fail when JUnit test case fails' do
134
+ write 'src/test/java/FailingTest.java', <<-JAVA
135
+ public class FailingTest extends junit.framework.TestCase {
136
+ public void testFailure() {
137
+ assertTrue(false);
138
+ }
139
+ }
140
+ JAVA
141
+ lambda { define('foo').test.invoke }.should raise_error(RuntimeError, /Tests failed/) rescue nil
142
+ end
143
+
144
+ it 'should report failed test names' do
145
+ write 'src/test/java/FailingTest.java', <<-JAVA
146
+ public class FailingTest extends junit.framework.TestCase {
147
+ public void testFailure() {
148
+ assertTrue(false);
149
+ }
150
+ }
151
+ JAVA
152
+ define('foo').test.invoke rescue
153
+ project('foo').test.failed_tests.should include('FailingTest')
154
+ end
155
+
156
+ it 'should report to reports/junit' do
157
+ write 'src/test/java/PassingTest.java', <<-JAVA
158
+ public class PassingTest extends junit.framework.TestCase {
159
+ public void testNothing() {}
160
+ }
161
+ JAVA
162
+ define 'foo' do
163
+ test.report_to.should be(file('reports/junit'))
164
+ end
165
+ project('foo').test.invoke
166
+ project('foo').file('reports/junit/TEST-PassingTest.txt').should exist
167
+ project('foo').file('reports/junit/TEST-PassingTest.xml').should exist
168
+ end
169
+
170
+ it 'should pass properties to JVM' do
171
+ write 'src/test/java/PropertyTest.java', <<-JAVA
172
+ public class PropertyTest extends junit.framework.TestCase {
173
+ public void testProperty() {
174
+ assertEquals("value", System.getProperty("name"));
175
+ }
176
+ }
177
+ JAVA
178
+ define('foo').test.using :properties=>{ 'name'=>'value' }
179
+ project('foo').test.invoke
180
+ end
181
+
182
+ it 'should set current directory' do
183
+ mkpath 'baz'
184
+ expected = File.expand_path('baz')
185
+ expected.gsub!('/', '\\') if expected =~ /^[A-Z]:/ # Java returns back slashed paths for windows
186
+ write 'baz/src/test/java/CurrentDirectoryTest.java', <<-JAVA
187
+ public class CurrentDirectoryTest extends junit.framework.TestCase {
188
+ public void testCurrentDirectory() throws Exception {
189
+ assertEquals(#{expected.inspect}, new java.io.File(".").getCanonicalPath());
190
+ }
191
+ }
192
+ JAVA
193
+ define 'bar' do
194
+ define 'baz' do
195
+ test.include 'CurrentDirectoryTest'
196
+ end
197
+ end
198
+ project('bar:baz').test.invoke
199
+ end
200
+
201
+ def fork_tests(mode)
202
+ write 'src/test/java/Shared.java', <<-JAVA
203
+ public class Shared {
204
+ public static boolean flag = false;
205
+ }
206
+ JAVA
207
+ write 'src/test/java/TestCase1.java', <<-JAVA
208
+ public class TestCase1 extends junit.framework.TestCase {
209
+ public void testSameVM() {
210
+ assertFalse(Shared.flag);
211
+ Shared.flag = true;
212
+ }
213
+ }
214
+ JAVA
215
+ write 'src/test/java/TestCase2.java', <<-JAVA
216
+ public class TestCase2 extends junit.framework.TestCase {
217
+ public void testSameVM() {
218
+ assertFalse(Shared.flag);
219
+ Shared.flag = true;
220
+ }
221
+ }
222
+ JAVA
223
+ define 'foo' do
224
+ test.using :fork=>mode, :fail_on_failure=>false
225
+ end
226
+ project('foo').test.invoke
227
+ end
228
+
229
+ it 'should run all test cases in same VM if fork is once' do
230
+ fork_tests :once
231
+ project('foo').test.failed_tests.size.should eql(1)
232
+ end
233
+
234
+ it 'should run each test case in separate same VM if fork is each' do
235
+ fork_tests :each
236
+ project('foo').test.failed_tests.should be_empty
237
+ end
238
+ end
239
+
240
+
241
+ describe Buildr::JUnit, 'report' do
242
+ it 'should default to the target directory reports/junit' do
243
+ JUnit.report.target.should eql('reports/junit')
244
+ end
245
+
246
+ it 'should generate report into the target directory' do
247
+ JUnit.report.target = 'test-report'
248
+ lambda { task('junit:report').invoke }.should change { File.exist?(JUnit.report.target) }.to(true)
249
+ end
250
+
251
+ it 'should clean after itself' do
252
+ mkpath JUnit.report.target
253
+ lambda { task('clean').invoke }.should change { File.exist?(JUnit.report.target) }.to(false)
254
+ end
255
+
256
+ it 'should generate a consolidated XML report' do
257
+ lambda { task('junit:report').invoke }.should change { File.exist?('reports/junit/TESTS-TestSuites.xml') }.to(true)
258
+ end
259
+
260
+ it 'should default to generating a report with frames' do
261
+ JUnit.report.frames.should be_true
262
+ end
263
+
264
+ it 'should generate single page when frames is false' do
265
+ JUnit.report.frames = false
266
+ task('junit:report').invoke
267
+ file('reports/junit/html/junit-noframes.html').should exist
268
+ end
269
+
270
+ it 'should generate frame page when frames is false' do
271
+ JUnit.report.frames = true
272
+ task('junit:report').invoke
273
+ file('reports/junit/html/index.html').should exist
274
+ end
275
+
276
+ it 'should generate reports from all projects that ran test cases' do
277
+ write 'src/test/java/TestSomething.java', <<-JAVA
278
+ public class TestSomething extends junit.framework.TestCase {
279
+ public void testNothing() {}
280
+ }
281
+ JAVA
282
+ define 'foo'
283
+ project('foo').test.invoke
284
+ task('junit:report').invoke
285
+ FileList['reports/junit/html/*TestSomething.html'].size.should be(1)
286
+ end
287
+
288
+ after do
289
+ JUnit.instance_eval { @report = nil }
290
+ end
291
+ end
292
+
293
+
294
+ describe Buildr::TestNG do
295
+ it 'should be selectable in project' do
296
+ define 'foo' do
297
+ test.using(:testng)
298
+ test.framework.should eql(:testng)
299
+ end
300
+ end
301
+
302
+ it 'should be selectable in parent project' do
303
+ write 'bar/src/test/java/TestCase.java'
304
+ define 'foo' do
305
+ test.using(:testng)
306
+ define 'bar'
307
+ end
308
+ project('foo:bar').test.framework.should eql(:testng)
309
+ end
310
+
311
+ it 'should include TestNG dependencies' do
312
+ define('foo') { test.using :testng }
313
+ project('foo').test.compile.dependencies.should include(*artifacts(TestNG::REQUIRES))
314
+ project('foo').test.dependencies.should include(*artifacts(TestNG::REQUIRES))
315
+ end
316
+
317
+ it 'should include TestNG dependencies' do
318
+ define('foo') { test.using :testng }
319
+ project('foo').test.compile.dependencies.should include(*artifacts(JMock::REQUIRES))
320
+ project('foo').test.dependencies.should include(*artifacts(JMock::REQUIRES))
321
+ end
322
+
323
+ it 'should include classes using TestNG annotations' do
324
+ write 'src/test/java/com/example/AnnotatedClass.java', <<-JAVA
325
+ package com.example;
326
+ @org.testng.annotations.Test
327
+ public class AnnotatedClass { }
328
+ JAVA
329
+ write 'src/test/java/com/example/AnnotatedMethod.java', <<-JAVA
330
+ package com.example;
331
+ public class AnnotatedMethod {
332
+ @org.testng.annotations.Test
333
+ public void annotated() { }
334
+ }
335
+ JAVA
336
+ define('foo') { test.using(:testng) }
337
+ project('foo').test.invoke
338
+ project('foo').test.tests.should include('com.example.AnnotatedClass', 'com.example.AnnotatedMethod')
339
+ end
340
+
341
+ it 'should ignore classes not using TestNG annotations' do
342
+ write 'src/test/java/NotATestClass.java', 'public class NotATestClass {}'
343
+ define('foo') { test.using(:testng) }
344
+ project('foo').test.invoke
345
+ project('foo').test.tests.should be_empty
346
+ end
347
+
348
+ it 'should ignore inner classes' do
349
+ write 'src/test/java/InnerClassTest.java', <<-JAVA
350
+ @org.testng.annotations.Test
351
+ public class InnerClassTest {
352
+ public class InnerTest {
353
+ }
354
+ }
355
+ JAVA
356
+ define('foo') { test.using(:testng) }
357
+ project('foo').test.invoke
358
+ project('foo').test.tests.should eql(['InnerClassTest'])
359
+ end
360
+
361
+ it 'should pass when TestNG test case passes' do
362
+ write 'src/test/java/PassingTest.java', <<-JAVA
363
+ public class PassingTest {
364
+ @org.testng.annotations.Test
365
+ public void testNothing() {}
366
+ }
367
+ JAVA
368
+ define('foo') { test.using(:testng) }
369
+ lambda { project('foo').test.invoke }.should_not raise_error
370
+ end
371
+
372
+ it 'should fail when TestNG test case fails' do
373
+ write 'src/test/java/FailingTest.java', <<-JAVA
374
+ public class FailingTest {
375
+ @org.testng.annotations.Test
376
+ public void testNothing() {
377
+ org.testng.AssertJUnit.assertTrue(false);
378
+ }
379
+ }
380
+ JAVA
381
+ define('foo') { test.using(:testng) }
382
+ lambda { project('foo').test.invoke }.should raise_error(RuntimeError, /Tests failed/)
383
+ end
384
+
385
+ it 'should report failed test names' do
386
+ write 'src/test/java/FailingTest.java', <<-JAVA
387
+ public class FailingTest {
388
+ @org.testng.annotations.Test
389
+ public void testNothing() {
390
+ org.testng.AssertJUnit.assertTrue(false);
391
+ }
392
+ }
393
+ JAVA
394
+ define('foo') { test.using(:testng) }
395
+ project('foo').test.invoke rescue nil
396
+ project('foo').test.failed_tests.should include('FailingTest')
397
+ end
398
+
399
+ it 'should report to reports/testng' do
400
+ define('foo') { test.using(:testng) }
401
+ project('foo').test.report_to.should be(project('foo').file('reports/testng'))
402
+ end
403
+
404
+ it 'should generate reports' do
405
+ write 'src/test/java/PassingTest.java', <<-JAVA
406
+ public class PassingTest {
407
+ @org.testng.annotations.Test
408
+ public void testNothing() {}
409
+ }
410
+ JAVA
411
+ define('foo') { test.using(:testng) }
412
+ lambda { project('foo').test.invoke }.should change { File.exist?('reports/testng/foo/index.html') }.to(true)
413
+ end
414
+ end
@@ -0,0 +1,63 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ shared_examples_for 'packaging' do
18
+ it 'should create artifact of proper type' do
19
+ packaging = @packaging
20
+ package_type = @package_type || @packaging
21
+ define 'foo', :version=>'1.0' do
22
+ package(packaging).type.should eql(package_type) rescue exit!
23
+ end
24
+ end
25
+
26
+ it 'should create file with proper extension' do
27
+ packaging = @packaging
28
+ package_type = @package_type || @packaging
29
+ define 'foo', :version=>'1.0' do
30
+ package(packaging).to_s.should match(/.#{package_type}$/)
31
+ end
32
+ end
33
+
34
+ it 'should always return same task for the same package' do
35
+ packaging = @packaging
36
+ define 'foo', :version=>'1.0' do
37
+ package(packaging)
38
+ package(packaging, :id=>'other')
39
+ end
40
+ project('foo').packages.uniq.size.should eql(2)
41
+ end
42
+
43
+ it 'should complain if option not known' do
44
+ packaging = @packaging
45
+ define 'foo', :version=>'1.0' do
46
+ lambda { package(packaging, :unknown_option=>true) }.should raise_error(ArgumentError, /no such option/)
47
+ end
48
+ end
49
+
50
+ it 'should respond to with() and return self' do
51
+ packaging = @packaging
52
+ define 'foo', :version=>'1.0' do
53
+ package(packaging).with({}).should be(package(packaging))
54
+ end
55
+ end
56
+
57
+ it 'should respond to with() and complain if unknown option' do
58
+ packaging = @packaging
59
+ define 'foo', :version=>'1.0' do
60
+ lambda { package(packaging).with(:unknown_option=>true) }.should raise_error(ArgumentError, /does not support the option/)
61
+ end
62
+ end
63
+ end