-
Notifications
You must be signed in to change notification settings - Fork 0
/
running.html
298 lines (233 loc) · 10.7 KB
/
running.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>easyb makes it easy, man</title>
<meta name="keywords" content="BDD, behavior driven development, java, java bdd, groovy, groovy bdd,
groovy behavior driven development, java behavior driven development, ruby, rspec, easyb, easy bdd, maven,
ant bdd, maven bdd, ant"/>
<meta name="description" content="easyb is story verification framework built in the spirit of behavior driven development."/>
<link href="default.css" rel="stylesheet" type="text/css"/>
</head>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3500051-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<body>
<!-- start header -->
<div id="header">
<h1><a href="http://www.easyb.org"><span>easyb</span></a></h1>
<h2> -- BDD in java can't get any easier</h2>
</div>
<!-- end header -->
<!-- start page -->
<div id="page">
<!-- start content -->
<div id="content">
<div class="post">
<h2 class="title">Running easyb</h2>
<div class="entry">
<p>easyb can be invoked via:</p>
<ul>
<li><a href='#commandline'>the command line</a></li>
<li><a href='#ant'>Ant</a></li>
<li><a href='#maven'>Maven</a></li>
<li><a href='#intellij'>IntelliJ</a></li>
</ul>
<a name='commandline'>
<h2>Command line </h2>
</a>
<p>easyb comes with a command line runner that takes the name of a particular behavior or story you wish to run. You can
optionally pass in a few different flag options to output various report formats as well. </p>
<pre><code>
c:>java org.disco.easyb.BehaviorRunner my/path/to/MyStory.groovy
</code></pre>
<p>If no additional arguments are specified, you'll see a report printed to <code>System.out</code> that looks something
like this: </p>
<pre><code>
Running your story (Your.story)
Scenarios run: 1, Failures: 0, Pending: 0, Time Elapsed: 0.454 sec
1 behavior run with no failures
</code></pre>
<p>Want to run multiple behaviors or stories in a single run? Yep, easyb supports that too. Just pass multiple stories
on the command line.</p>
<pre><code>
c:>java org.disco.easyb.BehaviorRunner my/path/to/MyStory.groovy my/path/to/MySecondStory.groovy
</code></pre>
<p>Note, the runner doesn't care if you run a specification or a story-- they are run the same either way! Easy, eh?</p>
<h3>Story reporting via the command line</h3>
<p>You can generate a story printout of an easyb story by passing in the <code>-txtstory</code> flag as follows:</p>
<pre><code>
c:>java org.disco.easyb.BehaviorRunner my/path/to/MyStory.groovy \
-txtstory ./target/mystory.txt
</code></pre>
<p>Note, the line break in the above example is for formatting purposes only.</p>
<h3>XML reporting via the command line</h3>
<p>If you'd rather produce an XML report, just pass in the <code>-xmleasyb</code> flag and provide a path where the xml
report should be written. For instance, using the same example from earlier, if you'd rather have an XML report,
simply type:</p>
<pre><code>
c:>java org.disco.easyb.BehaviorRunner my/path/to/MyStory.groovy \
-xmleasyb my/path/report.xml
</code></pre>
<p>Note, the line break in the above example is for formatting purposes only.</p>
<a name='ant'>
<h2>Ant</h2>
</a>
<p>You can run your behaviors and stories via easyb's Ant task. It's easy:</p>
<ol>
<li>load the task (via Ant's <code>taskdef</code>)-- the class name is <code>org.disco.easyb.ant.BehaviorRunnerTask</code>
</li>
<li>provide a location for a report (or series of reports) and then provide a <code>fileset</code> with the location(s) of your behaviors
and stories
</li>
</ol>
<p>Defining the task looks like this:</p>
<pre><code>
<taskdef name="easyb" classname="org.disco.easyb.ant.BehaviorRunnerTask">
<classpath>
<pathelement location="${lib.dir}/release/easyb-xx.jar"/>
</classpath>
</taskdef>
</code></pre>
<p>Running the task looks like:</p>
<pre><code>
<easyb>
<classpath>
<path refid="build.classpath" />
<pathelement path="target/classes" />
</classpath>
<report location="target/story.txt" format="txtstory" />
<behaviors dir="${mybehaviors.dir}">
<include name="**/*Story.groovy"/>
</behaviors>
</easyb>
</code></pre>
<p>Produces output:</p>
<pre><code>
[easyb] Running story listener story (StoryListener.story)
[easyb] Scenarios run: 2, Failures: 0, Pending: 0, Time Elapsed: 0.06 sec
[easyb] 2 total behaviors run with no failures
[easyb] easyb execution passed
BUILD SUCCESSFUL
Total time: 3 seconds
</code></pre>
<h3>Failures</h3>
<p>The point of having your behaviors run as part of your build is to notify you when they catch possible code problems. easyb also allows a user specified property to be set to true if the build fails.</p>
<p>This property is called <code>failureProperty</code> and using it would look like this</p>
<pre><code>
<easyb failureProperty="easyb.failed">
</code></pre>
<p>That alone doesn't fail the build but puts the flexibility in your hands to fail it, print it or do nothing with it as you please. Here is a common example of using that property to fail a build:</p>
<pre><code>
<fail if="easyb.failed" message="Execution halted as behaviors failed"/>
</code></pre>
<p>Now when a behavior fails our build will halt with output like so:</p>
<pre><code>
[easyb] easyb is preparing to process 1 file(s)
[easyb] 9 behavior steps run , but status is failure! Total failures: 1
[easyb] Failure -> then the dealer should win in BlackjackStory.groovy
[easyb] VerificationException: expected lossss but was loss:
....
....
[easyb] specification failures detected!
[easyb] easyb execution FAILED
BUILD FAILED
/blah/blah/build.xml:75: easyb reported a failure
Total time: 3 seconds
</code></pre>
<p>Now you can be more confident that your build hasn't been broken by a change since you get instant feedback on behavior failures.</p>
<h3>Story Printing</h3>
<p>easyb embraces the idea that stories are a link between the business requirements and your code. To help use those stories when talking to your clients about requirements, easyb provides a way to print out just the stories without a lot of geeky code.</p>
<p>To print out a story report via Ant, simply create a <code>report</code> element with its <code>format</code> attribute set to <code>txtstory</code> as follows:</p>
<pre><code>
<report location="target/stories.txt" format="txtstory"/>
</code></pre>
<p>Here is some sample output:</p>
<pre><code>
9 behavior steps executed successfully
Story: blackjack
scenario tie game when cards are dealt but dealer gets higher card
given a game a blackjack game and both players have a score of 10
when the dealer gets an Ace and you get a 10
then the dealer should win
scenario tie game when cards are dealt but player gets higher card
given a game a blackjack game and both players have a score of 10
when the dealer gets a 10 and you get an Ace
then the player should win
</code></pre>
<p>That looks like something business users (or management) could understand-- they might even be able to *gasp* write them!</p>
<a name='maven'>
<h2>Maven</h2>
</a>
<p>You can also run your behaviors and stories via easyb's Maven plugin as well as generate HTML story reports. It's easy as fully explained on the <a href='https://github.com/easyb/easyb-maven-plugin'>maven-easyb-plugin</a> site. </p>
<a name='intellij'>
<h2>IntelliJ</h2>
</a>
<p>We have created an easyb plugin for IntelliJ that makes it super easyb to work with easyb specifications and to run and debug them. This plugin can be downloaded from <a href='http://easyb.googlecode.com/files/easyb-plugin-0.8.1.zip'>easyb-plugin-0.8.1.zip</a> and installing is as easyb as uncompressing this zip file into your IntelliJ plugin directory.
<p><strong>NOTE</strong> The current version of the easyb plugin for IntelliJ doesn't set file associations correctly. This can cause easyb stories and specifications to disappear from the IDE or be run as if they were groovy scripts. You can workaround this behavior by following these steps:</p>
<ol>
<li>Open the IntelliJ settings dialog</li>
<li>Select File Types</li>
<li>Locate the "easyb story" file type and remove all associations</li>
<li>Locate the "Groovy Scripts and Classes" file type and add ".story", "*Story.groovy", ".specification", and "*Specification.groovy"
</ol>
<p><strong>NOTE</strong> Also, with the current version of the plugin you will need to make easyb available on the classpath of your project. The next release of the plugin will make this unnecessary.</p>
</div>
</div>
</div>
<!-- end content -->
<!-- start sidebar -->
<div id="sidebar">
<ul>
<li>
<h2>Overview</h2>
<ul>
<li><a href="./index.html">Home</a></li>
<li><a href="./howtos.html">Stories</a></li>
<li><a href="./howtobb.html">Specifications</a></li>
<li><a href="./download.html">Download</a></li>
</ul>
</li>
<li>
<h2>Details</h2>
<ul>
<li><a href="./running.html">Running easyb</a></li>
<li><a href="./tutorialstack.html">An in-depth tutorial</a></li>
<li><a href="./dsls.html">easyb syntax specification</a></li>
<li><a href="./lic.html">License</a></li>
<li><a href="./source.html">Source code</a></li>
<li><a href="./contact.html">Contact</a></li>
</ul>
</li>
<li>
<h2>Plug-ins</h2>
<ul>
<li><a href="./dbunit.html">DbUnit plug-in</a></li>
</ul>
</li>
<li>
<h2>Resources</h2>
<ul>
<li><a href="http://dannorth.net/introducing-bdd/">Introducing BDD</a> (DanNorth.net)</li>
<li><a href="http://rspec.rubyforge.org/">RSpec</a></li>
<li><a href="http://groovy.codehaus.org/">Groovy</a></li>
<li><a href="http://code.google.com/p/easyb/w/list">easyb wiki</a></li>
<li><a href="./articles.html">Additional resources</a></li>
</ul>
</li>
</ul>
<div style="clear: both;"> </div>
</div>
<!-- end sidebar -->
</div>
<!-- end page -->
<div id="footer">
</div>
</body>
</html>