buildr 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +66 -4
- data/{README → README.rdoc} +29 -16
- data/Rakefile +16 -20
- data/_buildr +38 -0
- data/addon/buildr/cobertura.rb +49 -45
- data/addon/buildr/emma.rb +238 -0
- data/addon/buildr/jetty.rb +1 -1
- data/addon/buildr/nailgun.rb +585 -661
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
- data/bin/buildr +9 -2
- data/buildr.buildfile +53 -0
- data/buildr.gemspec +21 -14
- data/doc/css/default.css +51 -48
- data/doc/css/print.css +60 -55
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/pages/artifacts.textile +46 -156
- data/doc/pages/building.textile +63 -323
- data/doc/pages/contributing.textile +112 -102
- data/doc/pages/download.textile +19 -27
- data/doc/pages/extending.textile +27 -81
- data/doc/pages/getting_started.textile +44 -119
- data/doc/pages/index.textile +26 -47
- data/doc/pages/languages.textile +407 -0
- data/doc/pages/more_stuff.textile +92 -173
- data/doc/pages/packaging.textile +71 -239
- data/doc/pages/projects.textile +58 -233
- data/doc/pages/recipes.textile +19 -43
- data/doc/pages/settings_profiles.textile +39 -104
- data/doc/pages/testing.textile +41 -304
- data/doc/pages/troubleshooting.textile +29 -47
- data/doc/pages/whats_new.textile +69 -167
- data/doc/print.haml +0 -1
- data/doc/print.toc.yaml +1 -0
- data/doc/scripts/buildr-git.rb +1 -1
- data/doc/site.haml +1 -0
- data/doc/site.toc.yaml +8 -5
- data/{KEYS → etc/KEYS} +0 -0
- data/etc/git-svn-authors +16 -0
- data/lib/buildr.rb +2 -5
- data/lib/buildr/core/application.rb +192 -98
- data/lib/buildr/core/build.rb +140 -91
- data/lib/buildr/core/checks.rb +5 -5
- data/lib/buildr/core/common.rb +1 -1
- data/lib/buildr/core/compile.rb +12 -10
- data/lib/buildr/core/filter.rb +151 -46
- data/lib/buildr/core/generate.rb +9 -9
- data/lib/buildr/core/progressbar.rb +1 -1
- data/lib/buildr/core/project.rb +8 -7
- data/lib/buildr/core/test.rb +51 -26
- data/lib/buildr/core/transports.rb +22 -38
- data/lib/buildr/core/util.rb +78 -26
- data/lib/buildr/groovy.rb +18 -0
- data/lib/buildr/groovy/bdd.rb +105 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/ide/eclipse.rb +102 -71
- data/lib/buildr/ide/idea.rb +7 -12
- data/lib/buildr/ide/idea7x.rb +7 -8
- data/lib/buildr/java.rb +4 -7
- data/lib/buildr/java/ant.rb +26 -5
- data/lib/buildr/java/bdd.rb +449 -0
- data/lib/buildr/java/commands.rb +9 -9
- data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
- data/lib/buildr/java/jruby.rb +29 -11
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/packaging.rb +23 -16
- data/lib/buildr/java/pom.rb +1 -1
- data/lib/buildr/java/rjb.rb +21 -8
- data/lib/buildr/java/test_result.rb +308 -0
- data/lib/buildr/java/tests.rb +324 -0
- data/lib/buildr/packaging/artifact.rb +12 -11
- data/lib/buildr/packaging/artifact_namespace.rb +7 -4
- data/lib/buildr/packaging/gems.rb +3 -3
- data/lib/buildr/packaging/zip.rb +13 -10
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +19 -0
- data/lib/buildr/scala/compiler.rb +109 -0
- data/lib/buildr/scala/tests.rb +203 -0
- data/rakelib/apache.rake +71 -45
- data/rakelib/doc.rake +2 -2
- data/rakelib/package.rake +3 -2
- data/rakelib/rspec.rake +23 -21
- data/rakelib/setup.rake +34 -9
- data/rakelib/stage.rake +4 -1
- data/spec/addon/cobertura_spec.rb +77 -0
- data/spec/addon/emma_spec.rb +120 -0
- data/spec/addon/test_coverage_spec.rb +255 -0
- data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
- data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
- data/spec/core/build_spec.rb +415 -0
- data/spec/{checks_spec.rb → core/checks_spec.rb} +2 -2
- data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
- data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
- data/spec/core/generate_spec.rb +33 -0
- data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
- data/spec/{test_spec.rb → core/test_spec.rb} +222 -28
- data/spec/{transport_spec.rb → core/transport_spec.rb} +5 -9
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
- data/spec/ide/eclipse_spec.rb +243 -0
- data/spec/{java_spec.rb → java/ant.rb} +7 -17
- data/spec/java/bdd_spec.rb +358 -0
- data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
- data/spec/java/java_spec.rb +88 -0
- data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
- data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +31 -10
- data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
- data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +12 -5
- data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
- data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
- data/spec/sandbox.rb +22 -5
- data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
- data/spec/{scala_test_frameworks_spec.rb → scala/tests_spec.rb} +11 -12
- data/spec/spec_helpers.rb +38 -17
- metadata +103 -70
- data/lib/buildr/java/bdd_frameworks.rb +0 -265
- data/lib/buildr/java/groovyc.rb +0 -137
- data/lib/buildr/java/test_frameworks.rb +0 -450
- data/spec/build_spec.rb +0 -193
- data/spec/java_bdd_frameworks_spec.rb +0 -238
- data/spec/spec.opts +0 -6
@@ -3,10 +3,7 @@ h1. Settings/Profiles
|
|
3
3
|
|
4
4
|
h2. Environment Variables
|
5
5
|
|
6
|
-
Buildr uses several environment variables that help you control how it works.
|
7
|
-
Some environment variables you will only set once or change infrequently. You
|
8
|
-
can set these in your profile, OS settings or any tool you use to launch Buildr
|
9
|
-
(e.g. continuous integration).
|
6
|
+
Buildr uses several environment variables that help you control how it works. Some environment variables you will only set once or change infrequently. You can set these in your profile, OS settings or any tool you use to launch Buildr (e.g. continuous integration).
|
10
7
|
|
11
8
|
For example:
|
12
9
|
|
@@ -14,63 +11,42 @@ For example:
|
|
14
11
|
$ export HTTP_PROXY=http://myproxy:8080
|
15
12
|
}}}
|
16
13
|
|
17
|
-
There are other environment variables you will want to set when running Buildr,
|
18
|
-
for example, to do a full build without running the tests:
|
14
|
+
There are other environment variables you will want to set when running Buildr, for example, to do a full build without running the tests:
|
19
15
|
|
20
16
|
{{{!sh
|
21
17
|
$ buildr test=no
|
22
18
|
}}}
|
23
19
|
|
24
|
-
For convenience, when you set environment variables on the command line, the
|
25
|
-
variable name is case insensitive, you can use either @test=no@ or @TEST=no@.
|
26
|
-
Any other way (@export@, @ENV@, etc) the variable names are case sensitive.
|
20
|
+
For convenience, when you set environment variables on the command line, the variable name is case insensitive, you can use either @test=no@ or @TEST=no@. Any other way (@export@, @ENV@, etc) the variable names are case sensitive.
|
27
21
|
|
28
|
-
You can also set environment variables from within your Buildfile. For
|
29
|
-
example, if you discover that building your project requires gobs of JVM heap
|
30
|
-
space, and you want all other team members to run with the same settings:
|
22
|
+
You can also set environment variables from within your Buildfile. For example, if you discover that building your project requires gobs of JVM heap space, and you want all other team members to run with the same settings:
|
31
23
|
|
32
24
|
{{{!ruby
|
33
25
|
# This project builds a lot of code.
|
34
26
|
ENV['JAVA_OPTS'] ||= '-Xms1g -Xmx1g'
|
35
27
|
}}}
|
36
28
|
|
37
|
-
Make sure to set any environment variables at the very top of the Buildfile,
|
38
|
-
above any Ruby statement (even @require@).
|
29
|
+
Make sure to set any environment variables at the very top of the Buildfile, above any Ruby statement (even @require@).
|
39
30
|
|
40
|
-
p(tip). Using @||=@ sets the environment variable, if not already set, so
|
41
|
-
it's still possible for other developers to override this environment variable
|
42
|
-
without modifying the Buildfile.
|
31
|
+
p(tip). Using @||=@ sets the environment variable, if not already set, so it's still possible for other developers to override this environment variable without modifying the Buildfile.
|
43
32
|
|
44
33
|
Buildr supports the following environment variables:
|
45
34
|
|
46
35
|
|_. Variable |_. Description |
|
47
|
-
| @BUILDR_ENV@ | Environment name (development, production, test, etc).
|
48
|
-
|
49
|
-
| @DEBUG@ | Set to @no/off@ if you want Buildr to compile without
|
50
|
-
debugging information (default when running the @release@ task, see
|
51
|
-
"Compiling":building.html#compiling). |
|
36
|
+
| @BUILDR_ENV@ | Environment name (development, production, test, etc). Another way to set this is using the @-e@ command line option. |
|
37
|
+
| @DEBUG@ | Set to @no/off@ if you want Buildr to compile without debugging information (default when running the @release@ task, see "Compiling":building.html#compiling). |
|
52
38
|
| @HOME@ | Your home directory. |
|
53
|
-
| @HTTP_PROXY@ | URL for HTTP proxy server (see "Specifying
|
54
|
-
Repositories":artifacts.html#specifying_repositories). |
|
39
|
+
| @HTTP_PROXY@ | URL for HTTP proxy server (see "Specifying Repositories":artifacts.html#specifying_repositories). |
|
55
40
|
| @JAVA_HOME@ | Points to your JDK, required when using Java and Ant. |
|
56
41
|
| @JAVA_OPTS@ | Command line options to pass to the JDK (e.g. @'-Xms1g'@). |
|
57
|
-
| @M2_REPO@ | Location of the Maven2 local repository. Defaults to the
|
58
|
-
|
59
|
-
| @
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
servers, will use this environment variable. |
|
66
|
-
|
67
|
-
p(note). Buildr does not check any of the arguments in @JAVA_OPTS@. A common
|
68
|
-
mistake is to pass an option like @mx512mb@, where it should be @Xmx512mb@.
|
69
|
-
Make sure to double check @JAVA_OPTS@.
|
70
|
-
|
71
|
-
Some extensions may use additional environment variables, and of course, you
|
72
|
-
can always add your own. This example uses two environment variables for
|
73
|
-
specifying the username and password:
|
42
|
+
| @M2_REPO@ | Location of the Maven2 local repository. Defaults to the @.m2@ directory in your home directory (@ENV['HOME']@). |
|
43
|
+
| @NO_PROXY@ | Comma separated list of hosts and domain that should not be proxied (see "Specifying Repositories":artifacts.html#specifying_repositories). |
|
44
|
+
| @TEST@ | Set to @no/off@ to tell Buildr to skip tests, or @all@ to tell Buildr to run all tests and ignore failures (see "Running Tests":testing.html#running_tests). |
|
45
|
+
| @USER@ | Tasks that need your user name, for example to log to remote servers, will use this environment variable. |
|
46
|
+
|
47
|
+
p(note). Buildr does not check any of the arguments in @JAVA_OPTS@. A common mistake is to pass an option like @mx512mb@, where it should be @Xmx512mb@. Make sure to double check @JAVA_OPTS@.
|
48
|
+
|
49
|
+
Some extensions may use additional environment variables, and of course, you can always add your own. This example uses two environment variables for specifying the username and password:
|
74
50
|
|
75
51
|
{{{!ruby
|
76
52
|
repositories.upload_to[:username] = ENV['USERNAME']
|
@@ -80,17 +56,11 @@ repositories.upload_to[:password] = ENV['PASSWORD']
|
|
80
56
|
|
81
57
|
h2. Personal Settings
|
82
58
|
|
83
|
-
Some things clearly do not belong in the Buildfile. For example, the username
|
84
|
-
and password you use to upload releases. If you're working in a team or on an
|
85
|
-
open source project, you'd want to keep these in a separate place.
|
59
|
+
Some things clearly do not belong in the Buildfile. For example, the username and password you use to upload releases. If you're working in a team or on an open source project, you'd want to keep these in a separate place.
|
86
60
|
|
87
|
-
You may want to use personal settings for picking up a different location for
|
88
|
-
the local repository, or use a different set of preferred remote repositories,
|
89
|
-
and so forth.
|
61
|
+
You may want to use personal settings for picking up a different location for the local repository, or use a different set of preferred remote repositories, and so forth.
|
90
62
|
|
91
|
-
The prefered way to store personal settings is to create a @.buildr/settings.yaml@
|
92
|
-
file under your home directory. Settings stored there will be applied the same
|
93
|
-
across all builds.
|
63
|
+
The prefered way to store personal settings is to create a @.buildr/settings.yaml@ file under your home directory. Settings stored there will be applied the same across all builds.
|
94
64
|
|
95
65
|
Here's an example @settings.yaml@:
|
96
66
|
|
@@ -119,8 +89,7 @@ im:
|
|
119
89
|
pwd: secret
|
120
90
|
}}}
|
121
91
|
|
122
|
-
Later your buildfile or addons can reference user preferences using the
|
123
|
-
hash returned by the @Buildr.settings.user@ accessor.
|
92
|
+
Later your buildfile or addons can reference user preferences using the hash returned by the @Buildr.settings.user@ accessor.
|
124
93
|
|
125
94
|
{{{!ruby
|
126
95
|
task 'relase-notification' do
|
@@ -133,14 +102,9 @@ end
|
|
133
102
|
|
134
103
|
h2. Build Settings
|
135
104
|
|
136
|
-
Build settings are local to the project being built, and are placed in the
|
137
|
-
@build.yaml@ file located in the same directory that the @buildfile@. Normally
|
138
|
-
this file would be managed by the project revision control system, so settings
|
139
|
-
here are shared between developers.
|
105
|
+
Build settings are local to the project being built, and are placed in the @build.yaml@ file located in the same directory that the @buildfile@. Normally this file would be managed by the project revision control system, so settings here are shared between developers.
|
140
106
|
|
141
|
-
They help keep the buildfile and build.yaml file simple and readable, working
|
142
|
-
to the advantages of each one. Example for build settings are gems,
|
143
|
-
repositories and artifacts used by that build.
|
107
|
+
They help keep the buildfile and build.yaml file simple and readable, working to the advantages of each one. Example for build settings are gems, repositories and artifacts used by that build.
|
144
108
|
|
145
109
|
{{{!yaml
|
146
110
|
# This project requires the following ruby gems, buildr addons
|
@@ -171,12 +135,9 @@ jira:
|
|
171
135
|
uri: https://jira.corp.org
|
172
136
|
}}}
|
173
137
|
|
174
|
-
When buildr is loaded, required ruby gems will be installed if needed, thus adding
|
175
|
-
features like the imaginary twitter notifier addon.
|
138
|
+
When buildr is loaded, required ruby gems will be installed if needed, thus adding features like the imaginary twitter notifier addon.
|
176
139
|
|
177
|
-
Artifacts defined on @build.yaml@ can be referenced on your buildfile by supplying
|
178
|
-
the ruby symbol to the @Buildr.artifact@ and @Buildr.artifacts@ methods.
|
179
|
-
The @compile.with@, @test.with@ methods can also be given these names.
|
140
|
+
Artifacts defined on @build.yaml@ can be referenced on your buildfile by supplying the ruby symbol to the @Buildr.artifact@ and @Buildr.artifacts@ methods. The @compile.with@, @test.with@ methods can also be given these names.
|
180
141
|
|
181
142
|
{{{!ruby
|
182
143
|
define 'my_project' do
|
@@ -199,13 +160,9 @@ Build settings can be retreived using the @Buildr.settings.build@ accessor.
|
|
199
160
|
|
200
161
|
h2. Non constant settings
|
201
162
|
|
202
|
-
Before loading the Buildfile, Buildr will attempt to load two other files: the
|
203
|
-
@buildr.rb@ file it finds in your home directory, followed by the @buildr.rb@
|
204
|
-
file it finds in the build directory.
|
163
|
+
Before loading the Buildfile, Buildr will attempt to load two other files: the @buildr.rb@ file it finds in your home directory, followed by the @buildr.rb@ file it finds in the build directory.
|
205
164
|
|
206
|
-
The loading order allows you to place global settings that affect all your
|
207
|
-
builds in your home directory's @buildr.rb@, but also over-ride those with
|
208
|
-
settings for a given project.
|
165
|
+
The loading order allows you to place global settings that affect all your builds in your home directory's @buildr.rb@, but also over-ride those with settings for a given project.
|
209
166
|
|
210
167
|
Here's an example @buildr.rb@:
|
211
168
|
|
@@ -220,16 +177,9 @@ repositories.remote << 'http://inside-the-firewall'
|
|
220
177
|
|
221
178
|
h2. Environments
|
222
179
|
|
223
|
-
One common use case is adapting the build to different environments. For
|
224
|
-
example, to compile code with debugging information during development and
|
225
|
-
testing, but strip it for production. Another example is using different
|
226
|
-
databases for development, testing and production, or running services at
|
227
|
-
different URLs.
|
180
|
+
One common use case is adapting the build to different environments. For example, to compile code with debugging information during development and testing, but strip it for production. Another example is using different databases for development, testing and production, or running services at different URLs.
|
228
181
|
|
229
|
-
So let's start by talking about the build environment. Buildr has a global
|
230
|
-
attributes that indicates which environment it's running in, accessible from the
|
231
|
-
@environment@ method. You can set the current build environment in one of two
|
232
|
-
ways. Using the @-e/--environment@ command line option:
|
182
|
+
So let's start by talking about the build environment. Buildr has a global attributes that indicates which environment it's running in, accessible from the @environment@ method. You can set the current build environment in one of two ways. Using the @-e/--environment@ command line option:
|
233
183
|
|
234
184
|
{{{!sh
|
235
185
|
$ buildr -e test
|
@@ -244,11 +194,9 @@ $ buildr
|
|
244
194
|
(in /home/john/project, production)
|
245
195
|
}}}
|
246
196
|
|
247
|
-
Unless you tell it otherwise, Buildr assumes you're developing and sets the
|
248
|
-
environment to @development@.
|
197
|
+
Unless you tell it otherwise, Buildr assumes you're developing and sets the environment to @development@.
|
249
198
|
|
250
|
-
Here's a simple example for handling different environments within the
|
251
|
-
Buildfile:
|
199
|
+
Here's a simple example for handling different environments within the Buildfile:
|
252
200
|
|
253
201
|
{{{!ruby
|
254
202
|
project 'db-module' do
|
@@ -257,8 +205,7 @@ project 'db-module' do
|
|
257
205
|
end
|
258
206
|
}}}
|
259
207
|
|
260
|
-
We recommend picking a convention for your different environments and following
|
261
|
-
it across all your projects. For example:
|
208
|
+
We recommend picking a convention for your different environments and following it across all your projects. For example:
|
262
209
|
|
263
210
|
|_. Environment |_. Use when ... |
|
264
211
|
| development | Developing on your machine. |
|
@@ -268,12 +215,9 @@ it across all your projects. For example:
|
|
268
215
|
|
269
216
|
h2. Profiles
|
270
217
|
|
271
|
-
Different environments may require different configurations, some you will want
|
272
|
-
to control with code, others you will want to specify in the profiles file.
|
218
|
+
Different environments may require different configurations, some you will want to control with code, others you will want to specify in the profiles file.
|
273
219
|
|
274
|
-
The profiles file is a YAML file called @profiles.yaml@ that you place in the
|
275
|
-
same directory as the Buildfile. We selected YAML because it's easier to read
|
276
|
-
and edit than XML.
|
220
|
+
The profiles file is a YAML file called @profiles.yaml@ that you place in the same directory as the Buildfile. We selected YAML because it's easier to read and edit than XML.
|
277
221
|
|
278
222
|
For example, to support three different database configurations, we could write:
|
279
223
|
|
@@ -306,21 +250,13 @@ project 'db-module' do
|
|
306
250
|
end
|
307
251
|
}}}
|
308
252
|
|
309
|
-
The @profile@ method returns the current profile, selected based on the current
|
310
|
-
"environment":#environments. You can get a list of all profiles by calling
|
311
|
-
@profiles@.
|
312
|
-
|
313
|
-
When you run the above example in @development@, the current profile will
|
314
|
-
return the hash @{ 'db'=>'hsql', 'jdbc'=>'hsqldb:mem:devdb' }@.
|
253
|
+
The @profile@ method returns the current profile, selected based on the current "environment":#environments. You can get a list of all profiles by calling @profiles@.
|
315
254
|
|
316
|
-
|
317
|
-
projects, but sometimes the profiles end up being the same, so here's a trick
|
318
|
-
you can use to keep your profiles DRY.
|
255
|
+
When you run the above example in @development@, the current profile will return the hash @{ 'db'=>'hsql', 'jdbc'=>'hsqldb:mem:devdb' }@.
|
319
256
|
|
320
|
-
|
321
|
-
reference the anchored element (@*@) elsewhere, and merge one element into
|
322
|
-
another (@<<@). For example:
|
257
|
+
We recommend following conventions and using the same environments in all your projects, but sometimes the profiles end up being the same, so here's a trick you can use to keep your profiles DRY.
|
323
258
|
|
259
|
+
YAML allows you to use anchors (@&@), similar to ID attributes in XML, reference the anchored element (@*@) elsewhere, and merge one element into another (@<<@). For example:
|
324
260
|
|
325
261
|
{{{!yaml
|
326
262
|
# We'll reference this one as common.
|
@@ -335,5 +271,4 @@ test:
|
|
335
271
|
jdbc: hsqldb:file:testdb
|
336
272
|
}}}
|
337
273
|
|
338
|
-
You can "learn more about YAML here":http://www.yaml.org, and use this
|
339
|
-
handy "YAML quick reference":http://www.yaml.org/refcard.html.
|
274
|
+
You can "learn more about YAML here":http://www.yaml.org, and use this handy "YAML quick reference":http://www.yaml.org/refcard.html.
|
data/doc/pages/testing.textile
CHANGED
@@ -1,127 +1,26 @@
|
|
1
1
|
h1. Testing
|
2
2
|
|
3
|
-
Untested code is broken code, so we take testing seriously. Off the bat you
|
4
|
-
get to use either JUnit or TestNG for writing unit tests and integration tests.
|
5
|
-
And you can also add your own framework, or even script tests using Ruby. But
|
6
|
-
first, let's start with the basics.
|
3
|
+
Untested code is broken code, so we take testing seriously. Off the bat you get to use either JUnit or TestNG for writing unit tests and integration tests. And you can also add your own framework, or even script tests using Ruby. But= first, let's start with the basics.
|
7
4
|
|
8
5
|
|
9
6
|
h2. Writing Tests
|
10
7
|
|
11
|
-
Each project has a @TestTask@ that you can access using the @test@ method.
|
12
|
-
@TestTask@ reflects on the fact that each project has one task responsible for
|
13
|
-
getting the tests to run and acting on the results. But in fact there are
|
14
|
-
several tasks that do all the work, and a @test@ task coordinates all of that.
|
8
|
+
Each project has a @TestTask@ that you can access using the @test@ method. @TestTask@ reflects on the fact that each project has one task responsible for getting the tests to run and acting on the results. But in fact there are several tasks that do all the work, and a @test@ task coordinates all of that.
|
15
9
|
|
16
|
-
The first two tasks to execute are @test.compile@ and @test.resources@. They
|
17
|
-
work similar to @compile@ and @resources@, but uses a different set of
|
18
|
-
directories. For example, Java tests compile from the @src/test/java@
|
19
|
-
directory into the @target/test/classes@ directory, while resources are copied
|
20
|
-
from @src/test/resources@ into @target/test/resources@.
|
10
|
+
The first two tasks to execute are @test.compile@ and @test.resources@. They work similar to @compile@ and @resources@, but uses a different set of directories. For example, Java tests compile from the @src/test/java@ directory into the @target/test/classes@ directory, while resources are copied from @src/test/resources@ into @target/test/resources@.
|
21
11
|
|
22
|
-
The @test.compile@ task will run the @compile@ task first, then use the same
|
23
|
-
dependencies to compile the test classes. That much you already assumed. It
|
24
|
-
also adds the test framework (e.g. JUnit, TestNG) and JMock to the dependency
|
25
|
-
list. Less work for you.
|
12
|
+
The @test.compile@ task will run the @compile@ task first, then use the same dependencies to compile the test classes. That much you already assumed. It also adds the test framework (e.g. JUnit, TestNG) and JMock to the dependency list. Less work for you.
|
26
13
|
|
27
|
-
If you need more dependencies, the best way to add them is by calling
|
28
|
-
@test.with@. This method adds dependencies to both @compile.dependencies@ (for
|
29
|
-
compiling) and @test.dependencies@ (for running). You can manage these two
|
30
|
-
dependency lists separately, but using @test.with@ is good enough in more
|
31
|
-
cases.
|
14
|
+
If you need more dependencies, the best way to add them is by calling @test.with@. This method adds dependencies to both @compile.dependencies@ (for compiling) and @test.dependencies@ (for running). You can manage these two dependency lists separately, but using @test.with@ is good enough in more cases.
|
32
15
|
|
33
16
|
Once compiled, the @test@ task runs all the tests.
|
34
17
|
|
35
|
-
|
36
|
-
h2. Using JUnit
|
37
|
-
|
38
|
-
The default test framework for Java projects is JUnit 4.
|
39
|
-
|
40
|
-
When you use JUnit, the dependencies includes JUnit, and Buildr picks up all
|
41
|
-
test classes from the project by looking for classes that either subclass
|
42
|
-
@junit.framework.TestCase@, include methods annotated with @org.junit.Test@,
|
43
|
-
or test suites annotated with @org.org.junit.runner.RunWith@.
|
44
|
-
|
45
|
-
The JUnit test framework supports the following options:
|
46
|
-
|
47
|
-
|_. Option |_. Value |
|
48
|
-
| @:fork@ | VM forking, defaults to true. |
|
49
|
-
| @:clonevm@ | If true clone the VM each time it is forked. |
|
50
|
-
| @:properties@ | Hash of system properties available to the test case. |
|
51
|
-
| @:environment@ | Hash of environment variables available to the test case. |
|
52
|
-
| @:java_args@ | Arguments passed as is to the JVM. |
|
53
|
-
|
54
|
-
For example, to pass properties to the test case:
|
55
|
-
|
56
|
-
{{{!ruby
|
57
|
-
test.using :properties=>{ :currency=>'USD' }
|
58
|
-
}}}
|
59
|
-
|
60
|
-
There are benefits to running test cases in separate VMs. The default forking
|
61
|
-
mode is @:once@, and you can change it by setting the @:fork@ option.
|
62
|
-
|
63
|
-
|_. :fork=> |_. Behavior |
|
64
|
-
| @:once@ | Create one VM to run all test classes in the project, separate
|
65
|
-
VMs for each project. |
|
66
|
-
| @:each@ | Create one VM for each test case class. Slow but provides the
|
67
|
-
best isolation between test classes. |
|
68
|
-
| @false@ | Without forking, Buildr runs all test cases in a single VM. This
|
69
|
-
option runs fastest, but at the risk of running out of memory and causing test
|
70
|
-
cases to interfere with each other. |
|
71
|
-
|
72
|
-
You can see your tests running in the console, and if any tests fail, Buildr
|
73
|
-
will show a list of the failed test classes. In addition, JUnit produces text
|
74
|
-
and XML report files in the project's @reports/junit@ directory. You can use
|
75
|
-
that to get around too-much-stuff-in-my-console, or when using an automated
|
76
|
-
test system.
|
77
|
-
|
78
|
-
In addition, you can get a consolidated XML or HTML report by running the
|
79
|
-
@junit:report@ task. For example:
|
80
|
-
|
81
|
-
{{{!sh
|
82
|
-
$ buildr test junit:report test=all
|
83
|
-
$ firefox report/junit/html/index.html
|
84
|
-
}}}
|
85
|
-
|
86
|
-
The @junit:report@ task generates a report from all tests run so far. If you
|
87
|
-
run tests in a couple of projects, it will generate a report only for these two
|
88
|
-
projects. The example above runs tests in all the projects before generating
|
89
|
-
the reports.
|
90
|
-
|
91
|
-
|
92
|
-
h2. Using TestNG
|
93
|
-
|
94
|
-
You can also use TestNG in your project by telling your project to use TestNG:
|
95
|
-
|
96
|
-
{{{!ruby
|
97
|
-
test.using :testng
|
98
|
-
}}}
|
99
|
-
|
100
|
-
Like all other options you can set with @test.using@, it affects the projects
|
101
|
-
and all its sub-projects, so you only need to do this once at the top-most
|
102
|
-
project to use TestNG throughout. You can also mix TestNG and JUnit by setting
|
103
|
-
different projects to use different frameworks, but you can't mix both
|
104
|
-
frameworks in the same project. (And yes, @test.using :junit@ will switch a
|
105
|
-
project back to using JUnit)
|
106
|
-
|
107
|
-
TestNG works much like JUnit, it gets included in the dependency list, Buildr
|
108
|
-
picks test classes that contain methods annotated with
|
109
|
-
@org.testng.annotations.Test@, and generates test reports in
|
110
|
-
the @reports/testng@ directory. At the moment we don't have consolidated HTML
|
111
|
-
reports for TestNG.
|
112
|
-
|
113
|
-
The TestNG test framework supports the following options:
|
114
|
-
|
115
|
-
|_. Option |_. Value |
|
116
|
-
| @:properties@ | Hash of system properties available to the test case. |
|
117
|
-
| @:java_args@ | Arguments passed as is to the JVM. |
|
18
|
+
Different languages use different test frameworks. You can find out more about available test frameworks in the "Languages":languages.html section.
|
118
19
|
|
119
20
|
|
120
21
|
h2. Excluding Tests and Ignoring Failures
|
121
22
|
|
122
|
-
If you have a lot of tests that are failing or just hanging there collecting
|
123
|
-
dusts, you can tell Buildr to ignore them. You can either tell Buildr to only
|
124
|
-
run specific tests, for example:
|
23
|
+
If you have a lot of tests that are failing or just hanging there collecting dusts, you can tell Buildr to ignore them. You can either tell Buildr to only run specific tests, for example:
|
125
24
|
|
126
25
|
{{{!ruby
|
127
26
|
test.include 'com.acme.tests.passing.*'
|
@@ -133,19 +32,15 @@ Or tell it to exclude specific tests, for example:
|
|
133
32
|
test.exclude '*FailingTest', '*FailingWorseTest'
|
134
33
|
}}}
|
135
34
|
|
136
|
-
Note that we're always using the package qualified class name, and you can use
|
137
|
-
star (@*@) to substitute for any set of characters.
|
35
|
+
Note that we're always using the package qualified class name, and you can use star (@*@) to substitute for any set of characters.
|
138
36
|
|
139
|
-
When tests fail, Buildr fails the @test@ task. This is usually a good thing,
|
140
|
-
but you can also tell Buildr to ignore failures by resetting the
|
141
|
-
@:fail_on_failure@ option:
|
37
|
+
When tests fail, Buildr fails the @test@ task. This is usually a good thing, but you can also tell Buildr to ignore failures by resetting the @:fail_on_failure@ option:
|
142
38
|
|
143
39
|
{{{!ruby
|
144
40
|
test.using :fail_on_failure=>false
|
145
41
|
}}}
|
146
42
|
|
147
|
-
Besides giving you a free pass to ignore failures, you can use it for other
|
148
|
-
causes, for example, to be somewhat forgiving:
|
43
|
+
Besides giving you a free pass to ignore failures, you can use it for other causes, for example, to be somewhat forgiving:
|
149
44
|
|
150
45
|
{{{!ruby
|
151
46
|
test do
|
@@ -153,33 +48,20 @@ test do
|
|
153
48
|
end
|
154
49
|
}}}
|
155
50
|
|
156
|
-
The @failed_tests@ collection holds the names of all classes with failed tests.
|
157
|
-
And there's @classes@, which holds the names of all test classes. Ruby
|
158
|
-
arithmetic allows you to get the name of all passed test classes with a simple
|
159
|
-
@test.classes – test.failed_tests@. We'll let you imagine creative use for
|
160
|
-
these two.
|
51
|
+
The @failed_tests@ collection holds the names of all classes with failed tests. And there's @classes@, which holds the names of all test classes. Ruby arithmetic allows you to get the name of all passed test classes with a simple @test.classes – test.failed_tests@. We'll let you imagine creative use for these two.
|
161
52
|
|
162
53
|
|
163
54
|
h2. Running Tests
|
164
55
|
|
165
|
-
It's a good idea to run tests every time you change the source code, so we
|
166
|
-
wired the @build@ task to run the @test@ task at the end of the build. And
|
167
|
-
conveniently enough, the @build@ task is the default task, so another way to
|
168
|
-
build changes in your code and run your tests:
|
56
|
+
It's a good idea to run tests every time you change the source code, so we wired the @build@ task to run the @test@ task at the end of the build. And conveniently enough, the @build@ task is the default task, so another way to build changes in your code and run your tests:
|
169
57
|
|
170
58
|
{{{!sh
|
171
59
|
$ buildr
|
172
60
|
}}}
|
173
61
|
|
174
|
-
That only works with the local @build@ task and any local task that depends on
|
175
|
-
it, like @package@, @install@ and @upload@. Each project also has its own
|
176
|
-
@build@ task that does not invoke the @test@ task, so @buildr build@ will run
|
177
|
-
the tests cases, but @buildr foo:build@ will not.
|
62
|
+
That only works with the local @build@ task and any local task that depends on it, like @package@, @install@ and @upload@. Each project also has its own @build@ task that does not invoke the @test@ task, so @buildr build@ will run the tests cases, but @buildr foo:build@ will not.
|
178
63
|
|
179
|
-
While it's a good idea to always run your tests, it's not always possible.
|
180
|
-
There are two ways you can get @build@ to not run the @test@ task. You can set
|
181
|
-
the environment variable @test@ to @no@ (but @skip@ and @off@ will also work).
|
182
|
-
You can do that when running Buildr:
|
64
|
+
While it's a good idea to always run your tests, it's not always possible. There are two ways you can get @build@ to not run the @test@ task. You can set the environment variable @test@ to @no@ (but @skip@ and @off@ will also work). You can do that when running Buildr:
|
183
65
|
|
184
66
|
{{{!sh
|
185
67
|
$ buildr test=no
|
@@ -192,69 +74,42 @@ $ export TEST=no
|
|
192
74
|
$ buildr
|
193
75
|
}}}
|
194
76
|
|
195
|
-
If you're feeling really adventurous, you can also disable tests from your
|
196
|
-
Buildfile or @buildr.rb@ file, by setting @options.test = false@. We didn't say
|
197
|
-
it's a good idea, we're just giving you the option.
|
77
|
+
If you're feeling really adventurous, you can also disable tests from your Buildfile or @buildr.rb@ file, by setting @options.test = false@. We didn't say it's a good idea, we're just giving you the option.
|
198
78
|
|
199
|
-
The @test@ task is just smart enough to run all the tests it finds, but will
|
200
|
-
accept include/exclude patterns. Often enough you're only working on one
|
201
|
-
broken test and you only want to run that one test. Better than changing your
|
202
|
-
Buildfile, you can run the @test@ task with a pattern. For example:
|
79
|
+
The @test@ task is just smart enough to run all the tests it finds, but will accept include/exclude patterns. Often enough you're only working on one broken test and you only want to run that one test. Better than changing your Buildfile, you can run the @test@ task with a pattern. For example:
|
203
80
|
|
204
81
|
{{{!sh
|
205
82
|
$ buildr test:KillerAppTest
|
206
83
|
}}}
|
207
84
|
|
208
|
-
Buildr will then run only tests that match the pattern @KillerAppTest@. It
|
209
|
-
uses pattern matching, so @test:Foo@ will run @com.acme.FooTest@ and
|
210
|
-
@com.acme.FooBarTest@. With Java, you can use this to pick a class name, or a
|
211
|
-
package name to run all tests in that package, or any such combination. In
|
212
|
-
fact, you can specify several patterns separated with commas. For example:
|
85
|
+
Buildr will then run only tests that match the pattern @KillerAppTest@. It uses pattern matching, so @test:Foo@ will run @com.acme.FooTest@ and @com.acme.FooBarTest@. With Java, you can use this to pick a class name, or a package name to run all tests in that package, or any such combination. In fact, you can specify several patterns separated with commas. For example:
|
213
86
|
|
214
87
|
{{{!sh
|
215
88
|
$ buildr test:FooTest,BarTest
|
216
89
|
}}}
|
217
90
|
|
218
|
-
As you probably noticed, Buildr will stop your build at the first test that
|
219
|
-
fails. We think it's a good idea, except when it's not. If you're using a
|
220
|
-
continuous build system, you'll want a report of all the failed tests without
|
221
|
-
stopping at the first failure. To make that happen, set the environment
|
222
|
-
variable @test@ to "all", or the Buildr @options.test@ option to @:all@. For
|
223
|
-
example:
|
91
|
+
As you probably noticed, Buildr will stop your build at the first test that fails. We think it's a good idea, except when it's not. If you're using a continuous build system, you'll want a report of all the failed tests without stopping at the first failure. To make that happen, set the environment variable @test@ to "all", or the Buildr @options.test@ option to @:all@. For example:
|
224
92
|
|
225
93
|
{{{!sh
|
226
94
|
$ buildr package test=all
|
227
95
|
}}}
|
228
96
|
|
229
|
-
We're using @package@ and not @build@ above. When using a continuous build
|
230
|
-
system, you want to make sure that packages are created, contain the right
|
231
|
-
files, and also run the integration tests.
|
97
|
+
We're using @package@ and not @build@ above. When using a continuous build system, you want to make sure that packages are created, contain the right files, and also run the integration tests.
|
232
98
|
|
233
99
|
|
234
100
|
h2. Integration Tests
|
235
101
|
|
236
|
-
So far we talked about unit tests. Unit tests are run in isolation on the
|
237
|
-
specific project they test, in an isolated environment, generally with minimal
|
238
|
-
setup and teardown. You get a sense of that when we told you tests run after
|
239
|
-
the @build@ task, and include JMock in the dependency list.
|
102
|
+
So far we talked about unit tests. Unit tests are run in isolation on the specific project they test, in an isolated environment, generally with minimal setup and teardown. You get a sense of that when we told you tests run after the @build@ task, and include JMock in the dependency list.
|
240
103
|
|
241
|
-
In contrast, integration tests are run with a number of components, in an
|
242
|
-
environment that resembles production, often with more complicates setup and
|
243
|
-
teardown procedures. In this section we'll talk about the differences between
|
244
|
-
running unit and integration tests.
|
104
|
+
In contrast, integration tests are run with a number of components, in an environment that resembles production, often with more complicates setup and teardown procedures. In this section we'll talk about the differences between running unit and integration tests.
|
245
105
|
|
246
|
-
You write integration tests much the same way as you write unit tests, using
|
247
|
-
@test.compile@ and @test.resources@. However, you need to tell Buildr that
|
248
|
-
your tests will execute during integration test. To do so, add the following
|
249
|
-
line in your project definition:
|
106
|
+
You write integration tests much the same way as you write unit tests, using @test.compile@ and @test.resources@. However, you need to tell Buildr that your tests will execute during integration test. To do so, add the following line in your project definition:
|
250
107
|
|
251
108
|
{{{!ruby
|
252
109
|
test.using :integration
|
253
110
|
}}}
|
254
111
|
|
255
|
-
Typically you'll use unit tests in projects that create internal modules, such
|
256
|
-
as JARs, and integration tests in projects that create components, such as WARs
|
257
|
-
and EARs. You only need to use the @:integration@ option with the later.
|
112
|
+
Typically you'll use unit tests in projects that create internal modules, such as JARs, and integration tests in projects that create components, such as WARs and EARs. You only need to use the @:integration@ option with the later.
|
258
113
|
|
259
114
|
To run integration tests on the current project:
|
260
115
|
|
@@ -268,58 +123,32 @@ You can also run specific tests cases, for example:
|
|
268
123
|
$ buildr integration:ClientTest
|
269
124
|
}}}
|
270
125
|
|
271
|
-
If you run the @package@ task (or any task that depends on it, like @install@
|
272
|
-
and @upload@), Buildr will first run the @build@ task and all its unit tests,
|
273
|
-
and then create the packages and run the integration tests. That gives you
|
274
|
-
full coverage for your tests and ready to release packages. As with unit
|
275
|
-
tests, you can set the environment variable @test@ to "no" to skip integration
|
276
|
-
tests, or "all" to ignore failures.
|
126
|
+
If you run the @package@ task (or any task that depends on it, like @install@ and @upload@), Buildr will first run the @build@ task and all its unit tests, and then create the packages and run the integration tests. That gives you full coverage for your tests and ready to release packages. As with unit tests, you can set the environment variable @test@ to "no" to skip integration tests, or "all" to ignore failures.
|
277
127
|
|
278
128
|
|
279
129
|
h2. Using Setup and Teardown
|
280
130
|
|
281
|
-
Some tests need you to setup an environment before they run, and tear it down
|
282
|
-
afterwards. The test frameworks (JUnit, TestNG) allow you to do that for each
|
283
|
-
test. Buildr provides two additional mechanisms for dealing with more
|
284
|
-
complicated setup and teardown procedures.
|
131
|
+
Some tests need you to setup an environment before they run, and tear it down afterwards. The test frameworks (JUnit, TestNG) allow you to do that for each test. Buildr provides two additional mechanisms for dealing with more complicated setup and teardown procedures.
|
285
132
|
|
286
|
-
Integration tests run a setup task before the tests, and a teardown task
|
287
|
-
afterwards. You can use this task to setup a Web server for testing your Web
|
288
|
-
components, or a database server for testing persistence. You can access
|
289
|
-
either task by calling @integration.setup@ and @integration.teardown@. For
|
290
|
-
example:
|
133
|
+
Integration tests run a setup task before the tests, and a teardown task afterwards. You can use this task to setup a Web server for testing your Web components, or a database server for testing persistence. You can access either task by calling @integration.setup@ and @integration.teardown@. For example:
|
291
134
|
|
292
135
|
{{{!ruby
|
293
136
|
integration.setup { server.start ; server.deploy }
|
294
137
|
integration.teardown { server.stop }
|
295
138
|
}}}
|
296
139
|
|
297
|
-
Depending on your build, you may want to enhance the setup/teardown tasks from
|
298
|
-
within a project, for example, to populate the database with data used by that
|
299
|
-
project's test, or from outside the project definition, for example, to start
|
300
|
-
and stop the Web server.
|
140
|
+
Depending on your build, you may want to enhance the setup/teardown tasks from within a project, for example, to populate the database with data used by that project's test, or from outside the project definition, for example, to start and stop the Web server.
|
301
141
|
|
302
|
-
Likewise, each project has its own setup and teardown tasks that are run before
|
303
|
-
and after tests for that specific project. You can access these tasks using
|
304
|
-
@test.setup@ and @test.teardown@.
|
142
|
+
Likewise, each project has its own setup and teardown tasks that are run before and after tests for that specific project. You can access these tasks using @test.setup@ and @test.teardown@.
|
305
143
|
|
306
144
|
|
307
145
|
h2. Testing Your Build
|
308
146
|
|
309
|
-
So you got the build running and all the tests pass, binaries are shipping when
|
310
|
-
you find out some glaring omissions. The license file is empty, the localized
|
311
|
-
messages for Japanese are missing, the CSS files are not where you expect them
|
312
|
-
to be. The fact is, some errors slip by unit and integration tests. So how do
|
313
|
-
we make sure the same mistake doesn't happen again?
|
147
|
+
So you got the build running and all the tests pass, binaries are shipping when you find out some glaring omissions. The license file is empty, the localized messages for Japanese are missing, the CSS files are not where you expect them to be. The fact is, some errors slip by unit and integration tests. So how do we make sure the same mistake doesn't happen again?
|
314
148
|
|
315
|
-
Each project has a @check@ task that runs just after packaging. You can use
|
316
|
-
this task to verify that your build created the files you wanted it to create.
|
317
|
-
And to make it extremely convenient, we introduced the notion of expectations.
|
149
|
+
Each project has a @check@ task that runs just after packaging. You can use this task to verify that your build created the files you wanted it to create. And to make it extremely convenient, we introduced the notion of expectations.
|
318
150
|
|
319
|
-
You use the @check@ method to express and expectation. Buildr will then run
|
320
|
-
all these expectations against your project, and fail at the first expectation
|
321
|
-
that doesn't match. An expectation says three things. Let's look at a few
|
322
|
-
examples:
|
151
|
+
You use the @check@ method to express and expectation. Buildr will then run all these expectations against your project, and fail at the first expectation that doesn't match. An expectation says three things. Let's look at a few examples:
|
323
152
|
|
324
153
|
{{{!ruby
|
325
154
|
check package(:war), 'should exist' do
|
@@ -345,9 +174,7 @@ check file('target/classes/killerapp/Code.class'), 'should exist' do
|
|
345
174
|
end
|
346
175
|
}}}
|
347
176
|
|
348
|
-
The first argument is the subject, or the project if you skip the first
|
349
|
-
argument. The second argument is the description, optional, but we recommend
|
350
|
-
using it. The method @it@ returns the subject.
|
177
|
+
The first argument is the subject, or the project if you skip the first argument. The second argument is the description, optional, but we recommend using it. The method @it@ returns the subject.
|
351
178
|
|
352
179
|
You can also write the first expectation like this:
|
353
180
|
|
@@ -357,119 +184,29 @@ check do
|
|
357
184
|
end
|
358
185
|
}}}
|
359
186
|
|
360
|
-
We recommend using the subject and description, they make your build easier to
|
361
|
-
read and maintain, and produce better error messages.
|
187
|
+
We recommend using the subject and description, they make your build easier to read and maintain, and produce better error messages.
|
362
188
|
|
363
|
-
There are two methods you can call on just about any object, called @should@
|
364
|
-
and @should_not@. Each method takes an argument, a matcher, and executes that
|
365
|
-
matcher. If the matcher returns false, @should@ fails. You can figure out
|
366
|
-
what @should_not@ does in the same case.
|
189
|
+
There are two methods you can call on just about any object, called @should@ and @should_not@. Each method takes an argument, a matcher, and executes that matcher. If the matcher returns false, @should@ fails. You can figure out what @should_not@ does in the same case.
|
367
190
|
|
368
191
|
Buildr provides the following matchers:
|
369
192
|
|
370
193
|
|_. Method |_. Checks that ... |
|
371
194
|
| @exist@ | Given a file task checks that the file (or directory) exists. |
|
372
195
|
| @empty@ | Given a file task checks that the file (or directory) is empty. |
|
373
|
-
| @contain@ | Given a file task referencing a file, checks its contents, using
|
374
|
-
string or regular expression. For a file task referencing a directory, checks
|
375
|
-
that it contains the specified files; global patterns using @*@ and @**@ are
|
376
|
-
allowed. |
|
196
|
+
| @contain@ | Given a file task referencing a file, checks its contents, using string or regular expression. For a file task referencing a directory, checks that it contains the specified files; global patterns using @*@ and @**@ are allowed. |
|
377
197
|
|
378
|
-
All these matchers operate against a file task. If you run them against a
|
379
|
-
ZipTask (including JAR, WAR, etc) they can also check the contents of the ZIP
|
380
|
-
file. And as you can see in the examples above, you can also run them against
|
381
|
-
a path in a ZIP file, checking its contents as if it was a directory, or
|
382
|
-
against an entry in a ZIP file, checking the content of that file.
|
198
|
+
All these matchers operate against a file task. If you run them against a ZipTask (including JAR, WAR, etc) they can also check the contents of the ZIP file. And as you can see in the examples above, you can also run them against a path in a ZIP file, checking its contents as if it was a directory, or against an entry in a ZIP file, checking the content of that file.
|
383
199
|
|
384
|
-
p(note). The @package@ method returns a package task based on packaging type,
|
385
|
-
identifier, group, version and classifier. The last four are inferred, but if
|
386
|
-
you create a package with different specifications (for example, you specify a
|
387
|
-
classifier) your checks must call @package@ with the same qualifying arguments
|
388
|
-
to return the very same package task.
|
200
|
+
p(note). The @package@ method returns a package task based on packaging type, identifier, group, version and classifier. The last four are inferred, but if you create a package with different specifications (for example, you specify a classifier) your checks must call @package@ with the same qualifying arguments to return the very same package task.
|
389
201
|
|
390
|
-
Buildr expectations are based on RSpec. "RSpec":http://rspec.info/ is the
|
391
|
-
behavior-driven development framework we use to test Buildr itself. Check the
|
392
|
-
RSpec documentation if want to see all the supported matchers, or want to write
|
393
|
-
your own.
|
202
|
+
Buildr expectations are based on RSpec. "RSpec":http://rspec.info/ is the behavior-driven development framework we use to test Buildr itself. Check the RSpec documentation if want to see all the supported matchers, or want to write your own.
|
394
203
|
|
395
204
|
|
396
205
|
h2. Behaviour-Driven Development
|
397
206
|
|
398
|
-
Buildr supports several Behaviour-Driven Development(BDD) frameworks for
|
399
|
-
testing your projects. Buildr follows each framework naming conventions,
|
400
|
-
searching for files under the @src/spec/{lang}@ directory.
|
401
|
-
|
402
|
-
|
403
|
-
h4. JBehave
|
404
|
-
|
405
|
-
"JBehave":http://jbehave.org/ is a pure Java BDD framework, stories and
|
406
|
-
behaviour specifications are written in the Java language.
|
407
|
-
|
408
|
-
To use JBehave in your project you can select it with @test.using :jbehave@.
|
409
|
-
|
410
|
-
This framework will search for the following patterns under your project:
|
411
|
-
|
412
|
-
{{{
|
413
|
-
src/spec/java/**/*Behaviour.java
|
414
|
-
}}}
|
415
|
-
|
416
|
-
Supports the following options:
|
417
|
-
|
418
|
-
|_. Option |_. Value |
|
419
|
-
| @:properties@ | Hash of system properties available to the test case. |
|
420
|
-
| @:java_args@ | Arguments passed as is to the JVM. |
|
421
|
-
|
422
|
-
|
423
|
-
h4. RSpec
|
424
|
-
|
425
|
-
"RSpec":http://rspec.info/ is the de-facto BDD framework for ruby. It's the
|
426
|
-
framework used to test Buildr itself.
|
427
|
-
|
428
|
-
Specifications are written in "Ruby":http://www.ruby-lang.org/en/ language, but
|
429
|
-
are run by using "JRuby":http://jruby.codehaus.org/. That means you have
|
430
|
-
access to all your Java classes and any Java or Ruby tool out there.
|
431
|
-
|
432
|
-
To use this framework in your project you can select it with @test.using
|
433
|
-
:rspec@.
|
434
|
-
|
435
|
-
This framework will search for the following patterns under your project:
|
436
|
-
|
437
|
-
{{{
|
438
|
-
src/spec/ruby/**/*_spec.rb
|
439
|
-
}}}
|
440
|
-
|
441
|
-
Supports the following options:
|
442
|
-
|
443
|
-
|_. Option |_. Value |
|
444
|
-
| @:properties@ | Hash of system properties available to the test case. |
|
445
|
-
| @:java_args@ | Arguments passed as is to the JVM. |
|
446
|
-
|
447
|
-
|
448
|
-
h4. EasyB
|
449
|
-
|
450
|
-
"EasyB":http://www.easyb.org/ is a BDD framework using
|
451
|
-
"Groovy":http://groovy.codehaus.org/.
|
452
|
-
|
453
|
-
Specifications are written in the Groovy language, of course you get seamless
|
454
|
-
Java integration as with all things groovy.
|
455
|
-
|
456
|
-
To use this framework in your project you can select it with @test.using
|
457
|
-
:easyb@.
|
458
|
-
|
459
|
-
This framework will search for the following patterns under your project:
|
460
|
-
|
461
|
-
{{{
|
462
|
-
src/spec/groovy/**/*Behavior.groovy
|
463
|
-
src/spec/groovy/**/*Story.groovy
|
464
|
-
}}}
|
465
|
-
|
466
|
-
Supports the following options:
|
207
|
+
Buildr supports several Behaviour-Driven Development(BDD) frameworks for testing your projects. Buildr follows each framework naming conventions, searching for files under the @src/spec/{lang}@ directory.
|
467
208
|
|
468
|
-
|
469
|
-
| @:properties@ | Hash of system properties available to the test case. |
|
470
|
-
| @:java_args@ | Arguments passed as is to the JVM. |
|
471
|
-
| @:format@ | Report format, either @:txt@ or @:xml@ |
|
209
|
+
You can learn more about each BDD framework in the "Languages":languages.html section.
|
472
210
|
|
473
211
|
|
474
|
-
Next, let's talk about "customizing your environment and using
|
475
|
-
profiles":settings_profiles.html
|
212
|
+
Next, let's talk about "customizing your environment and using profiles":settings_profiles.html
|