ittayd-buildr 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +62 -9
- data/NOTICE +1 -1
- data/README.rdoc +9 -21
- data/Rakefile +20 -39
- data/_buildr +1 -0
- data/{spec/java/ant.rb → _jbuildr} +11 -15
- metadata +30 -210
- data/DISCLAIMER +0 -7
- data/addon/buildr/antlr.rb +0 -65
- data/addon/buildr/cobertura.rb +0 -22
- data/addon/buildr/drb.rb +0 -281
- data/addon/buildr/emma.rb +0 -22
- data/addon/buildr/hibernate.rb +0 -142
- data/addon/buildr/javacc.rb +0 -85
- data/addon/buildr/jdepend.rb +0 -60
- data/addon/buildr/jetty.rb +0 -248
- data/addon/buildr/jibx.rb +0 -86
- data/addon/buildr/nailgun.rb +0 -221
- data/addon/buildr/openjpa.rb +0 -90
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +0 -41
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.java +0 -144
- data/addon/buildr/path.rb +0 -136
- data/addon/buildr/xmlbeans.rb +0 -93
- data/buildr.buildfile +0 -53
- data/buildr.gemspec +0 -58
- data/doc/css/default.css +0 -228
- data/doc/css/print.css +0 -100
- data/doc/css/syntax.css +0 -52
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/pages/artifacts.textile +0 -207
- data/doc/pages/building.textile +0 -240
- data/doc/pages/contributing.textile +0 -208
- data/doc/pages/download.textile +0 -62
- data/doc/pages/extending.textile +0 -175
- data/doc/pages/getting_started.textile +0 -273
- data/doc/pages/index.textile +0 -42
- data/doc/pages/languages.textile +0 -407
- data/doc/pages/mailing_lists.textile +0 -17
- data/doc/pages/more_stuff.textile +0 -314
- data/doc/pages/packaging.textile +0 -427
- data/doc/pages/projects.textile +0 -274
- data/doc/pages/recipes.textile +0 -103
- data/doc/pages/settings_profiles.textile +0 -274
- data/doc/pages/testing.textile +0 -212
- data/doc/pages/troubleshooting.textile +0 -103
- data/doc/pages/whats_new.textile +0 -323
- data/doc/print.haml +0 -51
- data/doc/print.toc.yaml +0 -29
- data/doc/scripts/buildr-git.rb +0 -412
- data/doc/scripts/install-jruby.sh +0 -44
- data/doc/scripts/install-linux.sh +0 -64
- data/doc/scripts/install-osx.sh +0 -52
- data/doc/site.haml +0 -56
- data/doc/site.toc.yaml +0 -47
- data/etc/KEYS +0 -151
- data/etc/git-svn-authors +0 -16
- data/lib/buildr.rb +0 -33
- data/lib/buildr/core.rb +0 -29
- data/lib/buildr/core/application.rb +0 -665
- data/lib/buildr/core/build.rb +0 -311
- data/lib/buildr/core/checks.rb +0 -254
- data/lib/buildr/core/common.rb +0 -150
- data/lib/buildr/core/compile.rb +0 -590
- data/lib/buildr/core/environment.rb +0 -117
- data/lib/buildr/core/filter.rb +0 -366
- data/lib/buildr/core/generate.rb +0 -195
- data/lib/buildr/core/help.rb +0 -119
- data/lib/buildr/core/osx.rb +0 -49
- data/lib/buildr/core/progressbar.rb +0 -156
- data/lib/buildr/core/project.rb +0 -923
- data/lib/buildr/core/test.rb +0 -715
- data/lib/buildr/core/transports.rb +0 -560
- data/lib/buildr/core/util.rb +0 -294
- data/lib/buildr/groovy.rb +0 -18
- data/lib/buildr/groovy/bdd.rb +0 -106
- data/lib/buildr/groovy/compiler.rb +0 -138
- data/lib/buildr/ide.rb +0 -19
- data/lib/buildr/ide/eclipse.rb +0 -222
- data/lib/buildr/ide/idea.ipr.template +0 -300
- data/lib/buildr/ide/idea.rb +0 -190
- data/lib/buildr/ide/idea7x.ipr.template +0 -290
- data/lib/buildr/ide/idea7x.rb +0 -212
- data/lib/buildr/java.rb +0 -23
- data/lib/buildr/java/ant.rb +0 -92
- data/lib/buildr/java/bdd.rb +0 -451
- data/lib/buildr/java/cobertura.rb +0 -236
- data/lib/buildr/java/commands.rb +0 -211
- data/lib/buildr/java/compiler.rb +0 -348
- data/lib/buildr/java/deprecated.rb +0 -141
- data/lib/buildr/java/emma.rb +0 -238
- data/lib/buildr/java/jruby.rb +0 -117
- data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +0 -119
- data/lib/buildr/java/packaging.rb +0 -717
- data/lib/buildr/java/pom.rb +0 -174
- data/lib/buildr/java/rjb.rb +0 -155
- data/lib/buildr/java/test_result.rb +0 -307
- data/lib/buildr/java/tests.rb +0 -329
- data/lib/buildr/java/version_requirement.rb +0 -172
- data/lib/buildr/packaging.rb +0 -24
- data/lib/buildr/packaging/archive.rb +0 -488
- data/lib/buildr/packaging/artifact.rb +0 -759
- data/lib/buildr/packaging/artifact_namespace.rb +0 -972
- data/lib/buildr/packaging/artifact_search.rb +0 -140
- data/lib/buildr/packaging/gems.rb +0 -102
- data/lib/buildr/packaging/package.rb +0 -233
- data/lib/buildr/packaging/tar.rb +0 -186
- data/lib/buildr/packaging/version_requirement.rb +0 -172
- data/lib/buildr/packaging/zip.rb +0 -64
- data/lib/buildr/packaging/ziptask.rb +0 -313
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +0 -19
- data/lib/buildr/scala/compiler.rb +0 -109
- data/lib/buildr/scala/tests.rb +0 -203
- data/rakelib/apache.rake +0 -191
- data/rakelib/changelog.rake +0 -57
- data/rakelib/doc.rake +0 -103
- data/rakelib/package.rake +0 -76
- data/rakelib/release.rake +0 -65
- data/rakelib/rspec.rake +0 -83
- data/rakelib/rubyforge.rake +0 -56
- data/rakelib/scm.rake +0 -49
- data/rakelib/setup.rake +0 -81
- data/rakelib/stage.rake +0 -48
- data/spec/addon/drb_spec.rb +0 -328
- data/spec/core/application_spec.rb +0 -419
- data/spec/core/build_spec.rb +0 -423
- data/spec/core/checks_spec.rb +0 -519
- data/spec/core/common_spec.rb +0 -670
- data/spec/core/compile_spec.rb +0 -582
- data/spec/core/generate_spec.rb +0 -33
- data/spec/core/project_spec.rb +0 -776
- data/spec/core/test_spec.rb +0 -1098
- data/spec/core/transport_spec.rb +0 -500
- data/spec/groovy/bdd_spec.rb +0 -80
- data/spec/groovy/compiler_spec.rb +0 -239
- data/spec/ide/eclipse_spec.rb +0 -311
- data/spec/java/bdd_spec.rb +0 -358
- data/spec/java/cobertura_spec.rb +0 -77
- data/spec/java/compiler_spec.rb +0 -446
- data/spec/java/emma_spec.rb +0 -120
- data/spec/java/java_spec.rb +0 -96
- data/spec/java/packaging_spec.rb +0 -1120
- data/spec/java/test_coverage_spec.rb +0 -255
- data/spec/java/tests_spec.rb +0 -471
- data/spec/packaging/archive_spec.rb +0 -503
- data/spec/packaging/artifact_namespace_spec.rb +0 -646
- data/spec/packaging/artifact_spec.rb +0 -795
- data/spec/packaging/packaging_helper.rb +0 -63
- data/spec/packaging/packaging_spec.rb +0 -589
- data/spec/sandbox.rb +0 -139
- data/spec/scala/compiler_spec.rb +0 -228
- data/spec/scala/tests_spec.rb +0 -215
- data/spec/spec_helpers.rb +0 -327
- data/spec/version_requirement_spec.rb +0 -123
@@ -1,255 +0,0 @@
|
|
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
|
-
module TestCoverageHelper
|
21
|
-
def write_test options
|
22
|
-
write File.join(options[:in], "#{options[:for]}Test.java"),
|
23
|
-
"public class #{options[:for]}Test extends junit.framework.TestCase { public void test#{options[:for]}() { new #{options[:for]}(); } }"
|
24
|
-
end
|
25
|
-
|
26
|
-
# Rspec matcher using file glob patterns.
|
27
|
-
class FileNamePatternMatcher
|
28
|
-
def initialize(pattern)
|
29
|
-
@expected_pattern = pattern
|
30
|
-
@pattern_matcher = lambda { |filename| File.fnmatch? pattern, filename }
|
31
|
-
end
|
32
|
-
|
33
|
-
def matches?(directory)
|
34
|
-
@actual_filenames = Dir[File.join(directory,'*')]
|
35
|
-
@actual_filenames.any? &@pattern_matcher
|
36
|
-
end
|
37
|
-
|
38
|
-
def failure_message
|
39
|
-
"Expected to find at least one element matching '#{@expected_pattern}' among #{@actual_filenames.inspect}, but found none"
|
40
|
-
end
|
41
|
-
|
42
|
-
def negative_failure_message
|
43
|
-
"Expected to find no element matching '#{@expected_pattern}' among #{@actual_filenames.inspect}, but found matching element(s) #{@actual_filenames.select(&@pattern_matcher).inspect}"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Test if a directory contains at least one file matching a given glob pattern.
|
48
|
-
#
|
49
|
-
# For example, to check that a directory contains at least one HTML file:
|
50
|
-
# '/path/to/some/directory'.should have_files_matching('*.html')
|
51
|
-
def have_files_matching pattern
|
52
|
-
FileNamePatternMatcher.new pattern
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe 'test coverage tool', :shared=>true do
|
57
|
-
include TestCoverageHelper
|
58
|
-
|
59
|
-
def toolname
|
60
|
-
@tool_module.name.split('::').last.downcase
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_coverage_config
|
64
|
-
project('foo').send(toolname)
|
65
|
-
end
|
66
|
-
|
67
|
-
describe 'project-specific' do
|
68
|
-
|
69
|
-
before do
|
70
|
-
write 'src/main/java/Foo.java', 'public class Foo {}'
|
71
|
-
write_test :for=>'Foo', :in=>'src/test/java'
|
72
|
-
end
|
73
|
-
|
74
|
-
describe 'clean' do
|
75
|
-
before { define('foo') }
|
76
|
-
|
77
|
-
it 'should remove the instrumented directory' do
|
78
|
-
mkdir_p test_coverage_config.instrumented_dir.to_s
|
79
|
-
task('foo:clean').invoke
|
80
|
-
file(test_coverage_config.instrumented_dir).should_not exist
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'should remove the reporting directory' do
|
84
|
-
mkdir_p test_coverage_config.report_dir
|
85
|
-
task('foo:clean').invoke
|
86
|
-
file(test_coverage_config.report_dir).should_not exist
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe 'instrumented directory' do
|
91
|
-
it 'should have a default value' do
|
92
|
-
define('foo')
|
93
|
-
test_coverage_config.instrumented_dir.should point_to_path('target/instrumented/classes')
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'should be overridable' do
|
97
|
-
toolname = toolname()
|
98
|
-
define('foo') { send(toolname).instrumented_dir = path_to('target/coverage/classes') }
|
99
|
-
test_coverage_config.instrumented_dir.should point_to_path('target/coverage/classes')
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'should be created during instrumentation' do
|
103
|
-
define('foo')
|
104
|
-
task("foo:#{toolname}:instrument").invoke
|
105
|
-
file(test_coverage_config.instrumented_dir).should exist
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe 'instrumentation' do
|
110
|
-
def instrumented_dir
|
111
|
-
file(test_coverage_config.instrumented_dir)
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'should happen after compile' do
|
115
|
-
define('foo')
|
116
|
-
lambda { task("foo:#{toolname}:instrument").invoke }.should run_task('foo:compile')
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'should put classes from compile.target in the instrumented directory' do
|
120
|
-
define('foo')
|
121
|
-
task("foo:#{toolname}:instrument").invoke
|
122
|
-
Dir.entries(instrumented_dir.to_s).should == Dir.entries(project('foo').compile.target.to_s)
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'should touch instrumented directory if anything instrumented' do
|
126
|
-
a_long_time_ago = Time.now - 10
|
127
|
-
define('foo')
|
128
|
-
mkpath instrumented_dir.to_s
|
129
|
-
File.utime(a_long_time_ago, a_long_time_ago, instrumented_dir.to_s)
|
130
|
-
task("foo:#{toolname}:instrument").invoke
|
131
|
-
instrumented_dir.timestamp.should be_close(Time.now, 2)
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'should not touch instrumented directory if nothing instrumented' do
|
135
|
-
a_long_time_ago = Time.now - 10
|
136
|
-
define('foo').compile.invoke
|
137
|
-
mkpath instrumented_dir.to_s
|
138
|
-
[project('foo').compile.target, instrumented_dir].map(&:to_s).each { |dir| File.utime(a_long_time_ago, a_long_time_ago, dir) }
|
139
|
-
task("foo:#{toolname}:instrument").invoke
|
140
|
-
instrumented_dir.timestamp.should be_close(a_long_time_ago, 2)
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
describe 'testing classpath' do
|
145
|
-
it 'should give priority to instrumented classes over non-instrumented ones' do
|
146
|
-
define('foo')
|
147
|
-
depends = project('foo').test.dependencies
|
148
|
-
depends.index(test_coverage_config.instrumented_dir).should < depends.index(project('foo').compile.target)
|
149
|
-
end
|
150
|
-
|
151
|
-
it 'should have the test coverage tools artifacts' do
|
152
|
-
define('foo')
|
153
|
-
@tool_module.requires.each { |artifact| project('foo').test.dependencies.should include(artifact) }
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe 'html report' do
|
158
|
-
it 'should have html files' do
|
159
|
-
define('foo')
|
160
|
-
task("foo:#{toolname}:html").invoke
|
161
|
-
test_coverage_config.report_to(:html).should have_files_matching('*.html')
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'should contain full source code, including comments' do
|
165
|
-
write 'src/main/java/Foo.java',
|
166
|
-
'public class Foo { /* This comment is a TOKEN to check that test coverage reports include the source code */ }'
|
167
|
-
define('foo')
|
168
|
-
task("foo:#{toolname}:html").invoke
|
169
|
-
htlm_report_contents = Dir[File.join(test_coverage_config.report_dir, '**/*.html')].map{|path|File.open(path).read}.join
|
170
|
-
htlm_report_contents.should =~ /TOKEN/
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
describe 'cross-project' do
|
176
|
-
describe 'reporting' do
|
177
|
-
before do
|
178
|
-
write 'src/main/java/Foo.java', 'public class Foo {}'
|
179
|
-
write 'bar/src/main/java/Bar.java', 'public class Bar {}'
|
180
|
-
write_test :for=>'Bar', :in=>'bar/src/test/java'
|
181
|
-
define('foo') { define('bar') }
|
182
|
-
end
|
183
|
-
|
184
|
-
it 'should have a default target' do
|
185
|
-
@tool_module.report_to.should point_to_path(File.join('reports', toolname))
|
186
|
-
end
|
187
|
-
|
188
|
-
describe 'in html' do
|
189
|
-
it 'should be a defined task' do
|
190
|
-
Rake::Task.task_defined?("#{toolname}:html").should be(true)
|
191
|
-
end
|
192
|
-
|
193
|
-
it 'should happen after project instrumentation and testing' do
|
194
|
-
lambda { task("#{toolname}:html").invoke }.should run_tasks(["foo:#{toolname}:instrument", 'foo:bar:test'])
|
195
|
-
end
|
196
|
-
|
197
|
-
it 'should have html files' do
|
198
|
-
task("#{toolname}:html").invoke
|
199
|
-
@tool_module.report_to(:html).should have_files_matching('*.html')
|
200
|
-
end
|
201
|
-
|
202
|
-
it 'should contain full source code, including comments' do
|
203
|
-
write 'bar/src/main/java/Bar.java',
|
204
|
-
'public class Bar { /* This comment is a TOKEN to check that test coverage reports include the source code */ }'
|
205
|
-
task("#{toolname}:html").invoke
|
206
|
-
htlm_report_contents = Dir[File.join(@tool_module.report_to(:html), '**/*.html')].map{|path|File.open(path).read}.join
|
207
|
-
htlm_report_contents.should =~ /TOKEN/
|
208
|
-
end
|
209
|
-
|
210
|
-
it 'should handle gracefully a project with no source' do
|
211
|
-
define 'baz', :base_dir=>'baz'
|
212
|
-
task("#{toolname}:html").invoke
|
213
|
-
lambda { task("#{toolname}:html").invoke }.should_not raise_error
|
214
|
-
end
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
describe 'clean' do
|
219
|
-
it 'should remove the report directory' do
|
220
|
-
define('foo')
|
221
|
-
mkdir_p @tool_module.report_to
|
222
|
-
task("#{toolname}:clean").invoke
|
223
|
-
file(@tool_module.report_to).should_not exist
|
224
|
-
end
|
225
|
-
|
226
|
-
it 'should be called when calling global clean' do
|
227
|
-
define('foo')
|
228
|
-
lambda { task('clean').invoke }.should run_task("#{toolname}:clean")
|
229
|
-
end
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
describe 'project with no source' do
|
234
|
-
it 'should not define an html report task' do
|
235
|
-
define 'foo'
|
236
|
-
Rake::Task.task_defined?("foo:#{toolname}:html").should be(false)
|
237
|
-
end
|
238
|
-
|
239
|
-
it 'should not raise an error when instrumenting' do
|
240
|
-
define('foo')
|
241
|
-
lambda { task("foo:#{toolname}:instrument").invoke }.should_not raise_error
|
242
|
-
end
|
243
|
-
|
244
|
-
it 'should not add the instrumented directory to the testing classpath' do
|
245
|
-
define 'foo'
|
246
|
-
depends = project('foo').test.dependencies
|
247
|
-
depends.should_not include(test_coverage_config.instrumented_dir)
|
248
|
-
end
|
249
|
-
|
250
|
-
it 'should not add the test coverage tools artifacts to the testing classpath' do
|
251
|
-
define('foo')
|
252
|
-
@tool_module.requires.each { |artifact| project('foo').test.dependencies.should_not include(artifact) }
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end
|
data/spec/java/tests_spec.rb
DELETED
@@ -1,471 +0,0 @@
|
|
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(artifact("junit:junit:jar:#{JUnit.version}"))
|
40
|
-
project('foo').test.dependencies.should include(artifact("junit:junit:jar:#{JUnit.version}"))
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'should have REQUIRES up to version 1.5 since it was deprecated in 1.3.3' do
|
44
|
-
Buildr::VERSION.should < '1.5'
|
45
|
-
lambda { JUnit::REQUIRES }.should_not raise_error
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should pick JUnit version from junit build settings' do
|
49
|
-
Buildr::JUnit.instance_eval { @dependencies = nil }
|
50
|
-
write 'build.yaml', 'junit: 1.2.3'
|
51
|
-
define('foo') { test.using(:junit) }
|
52
|
-
project('foo').test.compile.dependencies.should include(artifact("junit:junit:jar:1.2.3"))
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'should include JMock dependencies' do
|
56
|
-
define('foo') { test.using(:junit) }
|
57
|
-
project('foo').test.compile.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
|
58
|
-
project('foo').test.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'should pick JUnit version from junit build settings' do
|
62
|
-
Buildr::JUnit.instance_eval { @dependencies = nil } # JUnit caches JMock dependencies
|
63
|
-
Buildr::JMock.instance_eval { @dependencies = nil }
|
64
|
-
write 'build.yaml', 'jmock: 1.2.3'
|
65
|
-
define('foo') { test.using(:junit) }
|
66
|
-
project('foo').test.compile.dependencies.should include(artifact("jmock:jmock:jar:1.2.3"))
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'should include public classes extending junit.framework.TestCase' do
|
70
|
-
write 'src/test/java/com/example/FirstTest.java', <<-JAVA
|
71
|
-
package com.example;
|
72
|
-
public class FirstTest extends junit.framework.TestCase {
|
73
|
-
public void testNothing() { }
|
74
|
-
}
|
75
|
-
JAVA
|
76
|
-
write 'src/test/java/com/example/AnotherOne.java', <<-JAVA
|
77
|
-
package com.example;
|
78
|
-
public class AnotherOne extends junit.framework.TestCase {
|
79
|
-
public void testNothing() { }
|
80
|
-
}
|
81
|
-
JAVA
|
82
|
-
define('foo').test.invoke
|
83
|
-
project('foo').test.tests.should include('com.example.FirstTest', 'com.example.AnotherOne')
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'should include public classes with annotated test cases' do
|
87
|
-
write 'src/test/java/com/example/FirstTest.java', <<-JAVA
|
88
|
-
package com.example;
|
89
|
-
import org.junit.Test;
|
90
|
-
public class FirstTest {
|
91
|
-
public void utilityMethod() { }
|
92
|
-
@Test
|
93
|
-
public void annotated() { }
|
94
|
-
}
|
95
|
-
JAVA
|
96
|
-
define('foo').test.invoke
|
97
|
-
project('foo').test.tests.should include('com.example.FirstTest')
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'should include public classes with RunWith annotation' do
|
101
|
-
write 'src/test/java/com/example/TestSuite.java', <<-JAVA
|
102
|
-
package com.example;
|
103
|
-
import org.junit.Test;
|
104
|
-
public class TestSuite {
|
105
|
-
@Test
|
106
|
-
public void annotated() { }
|
107
|
-
}
|
108
|
-
JAVA
|
109
|
-
write 'src/test/java/com/example/RunSuite.java', <<-JAVA
|
110
|
-
package com.example;
|
111
|
-
import org.junit.runner.RunWith;
|
112
|
-
import org.junit.runners.Suite;
|
113
|
-
@RunWith(Suite.class)
|
114
|
-
@Suite.SuiteClasses({TestSuite.class})
|
115
|
-
public class RunSuite {
|
116
|
-
}
|
117
|
-
JAVA
|
118
|
-
define('foo').test.invoke
|
119
|
-
project('foo').test.tests.should include('com.example.RunSuite')
|
120
|
-
end
|
121
|
-
|
122
|
-
it 'should ignore classes not extending junit.framework.TestCase' do
|
123
|
-
write 'src/test/java/NotATest.java', <<-JAVA
|
124
|
-
public class NotATest { }
|
125
|
-
JAVA
|
126
|
-
define('foo').test.invoke
|
127
|
-
project('foo').test.tests.should be_empty
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'should ignore inner classes' do
|
131
|
-
write 'src/test/java/InnerClassTest.java', <<-JAVA
|
132
|
-
public class InnerClassTest extends junit.framework.TestCase {
|
133
|
-
public void testNothing() { }
|
134
|
-
|
135
|
-
public class InnerTest extends junit.framework.TestCase {
|
136
|
-
public void testNothing() { }
|
137
|
-
}
|
138
|
-
}
|
139
|
-
JAVA
|
140
|
-
define('foo').test.invoke
|
141
|
-
project('foo').test.tests.should eql(['InnerClassTest'])
|
142
|
-
end
|
143
|
-
|
144
|
-
it 'should ignore abstract classes' do
|
145
|
-
write 'src/test/java/AbstractClassTest.java', <<-JAVA
|
146
|
-
public abstract class AbstractClassTest extends junit.framework.TestCase {
|
147
|
-
public void testNothing() { }
|
148
|
-
}
|
149
|
-
JAVA
|
150
|
-
define('foo').test.invoke
|
151
|
-
project('foo').test.tests.should be_empty
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'should ignore classes with no tests in them' do
|
155
|
-
write 'src/test/java/NoTests.java', <<-JAVA
|
156
|
-
public class NoTests {
|
157
|
-
}
|
158
|
-
JAVA
|
159
|
-
define('foo').test.invoke
|
160
|
-
project('foo').test.tests.should be_empty
|
161
|
-
end
|
162
|
-
|
163
|
-
it 'should pass when JUnit test case passes' do
|
164
|
-
write 'src/test/java/PassingTest.java', <<-JAVA
|
165
|
-
public class PassingTest extends junit.framework.TestCase {
|
166
|
-
public void testNothing() {}
|
167
|
-
}
|
168
|
-
JAVA
|
169
|
-
lambda { define('foo').test.invoke }.should_not raise_error
|
170
|
-
end
|
171
|
-
|
172
|
-
it 'should fail when JUnit test case fails' do
|
173
|
-
write 'src/test/java/FailingTest.java', <<-JAVA
|
174
|
-
public class FailingTest extends junit.framework.TestCase {
|
175
|
-
public void testFailure() {
|
176
|
-
assertTrue(false);
|
177
|
-
}
|
178
|
-
}
|
179
|
-
JAVA
|
180
|
-
lambda { define('foo').test.invoke }.should raise_error(RuntimeError, /Tests failed/) rescue nil
|
181
|
-
end
|
182
|
-
|
183
|
-
it 'should report failed test names' do
|
184
|
-
write 'src/test/java/FailingTest.java', <<-JAVA
|
185
|
-
public class FailingTest extends junit.framework.TestCase {
|
186
|
-
public void testFailure() {
|
187
|
-
assertTrue(false);
|
188
|
-
}
|
189
|
-
}
|
190
|
-
JAVA
|
191
|
-
define('foo').test.invoke rescue
|
192
|
-
project('foo').test.failed_tests.should include('FailingTest')
|
193
|
-
end
|
194
|
-
|
195
|
-
it 'should report to reports/junit' do
|
196
|
-
write 'src/test/java/PassingTest.java', <<-JAVA
|
197
|
-
public class PassingTest extends junit.framework.TestCase {
|
198
|
-
public void testNothing() {}
|
199
|
-
}
|
200
|
-
JAVA
|
201
|
-
define 'foo' do
|
202
|
-
test.report_to.should be(file('reports/junit'))
|
203
|
-
end
|
204
|
-
project('foo').test.invoke
|
205
|
-
project('foo').file('reports/junit/TEST-PassingTest.txt').should exist
|
206
|
-
project('foo').file('reports/junit/TEST-PassingTest.xml').should exist
|
207
|
-
end
|
208
|
-
|
209
|
-
it 'should pass properties to JVM' do
|
210
|
-
write 'src/test/java/PropertyTest.java', <<-JAVA
|
211
|
-
public class PropertyTest extends junit.framework.TestCase {
|
212
|
-
public void testProperty() {
|
213
|
-
assertEquals("value", System.getProperty("name"));
|
214
|
-
}
|
215
|
-
}
|
216
|
-
JAVA
|
217
|
-
define('foo').test.using :properties=>{ 'name'=>'value' }
|
218
|
-
project('foo').test.invoke
|
219
|
-
end
|
220
|
-
|
221
|
-
it 'should pass environment to JVM' do
|
222
|
-
write 'src/test/java/EnvironmentTest.java', <<-JAVA
|
223
|
-
public class EnvironmentTest extends junit.framework.TestCase {
|
224
|
-
public void testEnvironment() {
|
225
|
-
assertEquals("value", System.getenv("NAME"));
|
226
|
-
}
|
227
|
-
}
|
228
|
-
JAVA
|
229
|
-
define('foo').test.using :environment=>{ 'NAME'=>'value' }
|
230
|
-
project('foo').test.invoke
|
231
|
-
end
|
232
|
-
|
233
|
-
it 'should set current directory' do
|
234
|
-
mkpath 'baz'
|
235
|
-
expected = File.expand_path('baz')
|
236
|
-
expected.gsub!('/', '\\') if expected =~ /^[A-Z]:/ # Java returns back slashed paths for windows
|
237
|
-
write 'baz/src/test/java/CurrentDirectoryTest.java', <<-JAVA
|
238
|
-
public class CurrentDirectoryTest extends junit.framework.TestCase {
|
239
|
-
public void testCurrentDirectory() throws Exception {
|
240
|
-
assertEquals(#{expected.inspect}, new java.io.File(".").getCanonicalPath());
|
241
|
-
}
|
242
|
-
}
|
243
|
-
JAVA
|
244
|
-
define 'bar' do
|
245
|
-
define 'baz' do
|
246
|
-
test.include 'CurrentDirectoryTest'
|
247
|
-
end
|
248
|
-
end
|
249
|
-
project('bar:baz').test.invoke
|
250
|
-
end
|
251
|
-
|
252
|
-
def fork_tests(mode)
|
253
|
-
write 'src/test/java/Shared.java', <<-JAVA
|
254
|
-
public class Shared {
|
255
|
-
public static boolean flag = false;
|
256
|
-
}
|
257
|
-
JAVA
|
258
|
-
write 'src/test/java/TestCase1.java', <<-JAVA
|
259
|
-
public class TestCase1 extends junit.framework.TestCase {
|
260
|
-
public void testSameVM() {
|
261
|
-
assertFalse(Shared.flag);
|
262
|
-
Shared.flag = true;
|
263
|
-
}
|
264
|
-
}
|
265
|
-
JAVA
|
266
|
-
write 'src/test/java/TestCase2.java', <<-JAVA
|
267
|
-
public class TestCase2 extends junit.framework.TestCase {
|
268
|
-
public void testSameVM() {
|
269
|
-
assertFalse(Shared.flag);
|
270
|
-
Shared.flag = true;
|
271
|
-
}
|
272
|
-
}
|
273
|
-
JAVA
|
274
|
-
define 'foo' do
|
275
|
-
test.using :fork=>mode, :fail_on_failure=>false
|
276
|
-
end
|
277
|
-
project('foo').test.invoke
|
278
|
-
end
|
279
|
-
|
280
|
-
it 'should run all test cases in same VM if fork is once' do
|
281
|
-
fork_tests :once
|
282
|
-
project('foo').test.failed_tests.size.should eql(1)
|
283
|
-
end
|
284
|
-
|
285
|
-
it 'should run each test case in separate same VM if fork is each' do
|
286
|
-
fork_tests :each
|
287
|
-
project('foo').test.failed_tests.should be_empty
|
288
|
-
end
|
289
|
-
|
290
|
-
after do
|
291
|
-
# Yes, this is ugly. Better solution?
|
292
|
-
Buildr::JUnit.instance_eval { @dependencies = nil }
|
293
|
-
Buildr::JMock.instance_eval { @dependencies = nil }
|
294
|
-
end
|
295
|
-
end
|
296
|
-
|
297
|
-
|
298
|
-
describe Buildr::JUnit, 'report' do
|
299
|
-
it 'should default to the target directory reports/junit' do
|
300
|
-
JUnit.report.target.should eql('reports/junit')
|
301
|
-
end
|
302
|
-
|
303
|
-
it 'should generate report into the target directory' do
|
304
|
-
JUnit.report.target = 'test-report'
|
305
|
-
lambda { task('junit:report').invoke }.should change { File.exist?(JUnit.report.target) }.to(true)
|
306
|
-
end
|
307
|
-
|
308
|
-
it 'should clean after itself' do
|
309
|
-
mkpath JUnit.report.target
|
310
|
-
lambda { task('clean').invoke }.should change { File.exist?(JUnit.report.target) }.to(false)
|
311
|
-
end
|
312
|
-
|
313
|
-
it 'should generate a consolidated XML report' do
|
314
|
-
lambda { task('junit:report').invoke }.should change { File.exist?('reports/junit/TESTS-TestSuites.xml') }.to(true)
|
315
|
-
end
|
316
|
-
|
317
|
-
it 'should default to generating a report with frames' do
|
318
|
-
JUnit.report.frames.should be_true
|
319
|
-
end
|
320
|
-
|
321
|
-
it 'should generate single page when frames is false' do
|
322
|
-
JUnit.report.frames = false
|
323
|
-
task('junit:report').invoke
|
324
|
-
file('reports/junit/html/junit-noframes.html').should exist
|
325
|
-
end
|
326
|
-
|
327
|
-
it 'should generate frame page when frames is false' do
|
328
|
-
JUnit.report.frames = true
|
329
|
-
task('junit:report').invoke
|
330
|
-
file('reports/junit/html/index.html').should exist
|
331
|
-
end
|
332
|
-
|
333
|
-
it 'should generate reports from all projects that ran test cases' do
|
334
|
-
write 'src/test/java/TestSomething.java', <<-JAVA
|
335
|
-
public class TestSomething extends junit.framework.TestCase {
|
336
|
-
public void testNothing() {}
|
337
|
-
}
|
338
|
-
JAVA
|
339
|
-
define 'foo'
|
340
|
-
project('foo').test.invoke
|
341
|
-
task('junit:report').invoke
|
342
|
-
FileList['reports/junit/html/*TestSomething.html'].size.should be(1)
|
343
|
-
end
|
344
|
-
|
345
|
-
after do
|
346
|
-
JUnit.instance_eval { @report = nil }
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
|
351
|
-
describe Buildr::TestNG do
|
352
|
-
it 'should be selectable in project' do
|
353
|
-
define 'foo' do
|
354
|
-
test.using(:testng)
|
355
|
-
test.framework.should eql(:testng)
|
356
|
-
end
|
357
|
-
end
|
358
|
-
|
359
|
-
it 'should be selectable in parent project' do
|
360
|
-
write 'bar/src/test/java/TestCase.java'
|
361
|
-
define 'foo' do
|
362
|
-
test.using(:testng)
|
363
|
-
define 'bar'
|
364
|
-
end
|
365
|
-
project('foo:bar').test.framework.should eql(:testng)
|
366
|
-
end
|
367
|
-
|
368
|
-
it 'should include TestNG dependencies' do
|
369
|
-
define('foo') { test.using :testng }
|
370
|
-
project('foo').test.compile.dependencies.should include(artifact("org.testng:testng:jar:jdk15:#{TestNG.version}"))
|
371
|
-
project('foo').test.dependencies.should include(artifact("org.testng:testng:jar:jdk15:#{TestNG.version}"))
|
372
|
-
end
|
373
|
-
|
374
|
-
it 'should include TestNG dependencies' do
|
375
|
-
define('foo') { test.using :testng }
|
376
|
-
project('foo').test.compile.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
|
377
|
-
project('foo').test.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
|
378
|
-
end
|
379
|
-
|
380
|
-
it 'should include classes using TestNG annotations' do
|
381
|
-
write 'src/test/java/com/example/AnnotatedClass.java', <<-JAVA
|
382
|
-
package com.example;
|
383
|
-
@org.testng.annotations.Test
|
384
|
-
public class AnnotatedClass { }
|
385
|
-
JAVA
|
386
|
-
write 'src/test/java/com/example/AnnotatedMethod.java', <<-JAVA
|
387
|
-
package com.example;
|
388
|
-
public class AnnotatedMethod {
|
389
|
-
@org.testng.annotations.Test
|
390
|
-
public void annotated() { }
|
391
|
-
}
|
392
|
-
JAVA
|
393
|
-
define('foo') { test.using(:testng) }
|
394
|
-
project('foo').test.invoke
|
395
|
-
project('foo').test.tests.should include('com.example.AnnotatedClass', 'com.example.AnnotatedMethod')
|
396
|
-
end
|
397
|
-
|
398
|
-
it 'should ignore classes not using TestNG annotations' do
|
399
|
-
write 'src/test/java/NotATestClass.java', 'public class NotATestClass {}'
|
400
|
-
define('foo') { test.using(:testng) }
|
401
|
-
project('foo').test.invoke
|
402
|
-
project('foo').test.tests.should be_empty
|
403
|
-
end
|
404
|
-
|
405
|
-
it 'should ignore inner classes' do
|
406
|
-
write 'src/test/java/InnerClassTest.java', <<-JAVA
|
407
|
-
@org.testng.annotations.Test
|
408
|
-
public class InnerClassTest {
|
409
|
-
public class InnerTest {
|
410
|
-
}
|
411
|
-
}
|
412
|
-
JAVA
|
413
|
-
define('foo') { test.using(:testng) }
|
414
|
-
project('foo').test.invoke
|
415
|
-
project('foo').test.tests.should eql(['InnerClassTest'])
|
416
|
-
end
|
417
|
-
|
418
|
-
it 'should pass when TestNG test case passes' do
|
419
|
-
write 'src/test/java/PassingTest.java', <<-JAVA
|
420
|
-
public class PassingTest {
|
421
|
-
@org.testng.annotations.Test
|
422
|
-
public void testNothing() {}
|
423
|
-
}
|
424
|
-
JAVA
|
425
|
-
define('foo') { test.using(:testng) }
|
426
|
-
lambda { project('foo').test.invoke }.should_not raise_error
|
427
|
-
end
|
428
|
-
|
429
|
-
it 'should fail when TestNG test case fails' do
|
430
|
-
write 'src/test/java/FailingTest.java', <<-JAVA
|
431
|
-
public class FailingTest {
|
432
|
-
@org.testng.annotations.Test
|
433
|
-
public void testNothing() {
|
434
|
-
org.testng.AssertJUnit.assertTrue(false);
|
435
|
-
}
|
436
|
-
}
|
437
|
-
JAVA
|
438
|
-
define('foo') { test.using(:testng) }
|
439
|
-
lambda { project('foo').test.invoke }.should raise_error(RuntimeError, /Tests failed/)
|
440
|
-
end
|
441
|
-
|
442
|
-
it 'should report failed test names' do
|
443
|
-
write 'src/test/java/FailingTest.java', <<-JAVA
|
444
|
-
public class FailingTest {
|
445
|
-
@org.testng.annotations.Test
|
446
|
-
public void testNothing() {
|
447
|
-
org.testng.AssertJUnit.assertTrue(false);
|
448
|
-
}
|
449
|
-
}
|
450
|
-
JAVA
|
451
|
-
define('foo') { test.using(:testng) }
|
452
|
-
project('foo').test.invoke rescue nil
|
453
|
-
project('foo').test.failed_tests.should include('FailingTest')
|
454
|
-
end
|
455
|
-
|
456
|
-
it 'should report to reports/testng' do
|
457
|
-
define('foo') { test.using(:testng) }
|
458
|
-
project('foo').test.report_to.should be(project('foo').file('reports/testng'))
|
459
|
-
end
|
460
|
-
|
461
|
-
it 'should generate reports' do
|
462
|
-
write 'src/test/java/PassingTest.java', <<-JAVA
|
463
|
-
public class PassingTest {
|
464
|
-
@org.testng.annotations.Test
|
465
|
-
public void testNothing() {}
|
466
|
-
}
|
467
|
-
JAVA
|
468
|
-
define('foo') { test.using(:testng) }
|
469
|
-
lambda { project('foo').test.invoke }.should change { File.exist?('reports/testng/foo/index.html') }.to(true)
|
470
|
-
end
|
471
|
-
end
|