-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
575 lines (511 loc) · 18.3 KB
/
index.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Behat: make your app behave.</title>
<meta name="description" content="An introduction to behat">
<meta name="author" content="Rodrigo Aguilera">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/solarized.css" id="theme">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>Introduction to Behat</h1>
<h3>Make your app behave</h3>
<p>
<small>A talk by <a href="http://www.rodrigoaguilera.net">Rodrigo Aguilera</a> / <a href="http://twitter.com/marinero">@marinero</a></small>
</p>
<aside class="notes">
Thank you to the organization. <br>
I'm excited about behat.
</aside>
</section>
<section>
<h2>Hello There</h2>
<p>
<a href="https://www.drupal.org/u/rodrigoaguilera">https://www.drupal.org/u/rodrigoaguilera</a>
</p>
<p>
<img src="images/ymbralogo.png" alt="Logo Ymbra" style="border:0">
</p>
<aside class="notes">
I'm from Madrid, now I live in Barcelona. I'm 29. I work as a drupal developer at Ymbra, Citilab. <br>
I have a curiosity to improve process. <br>
Previously on: servers, multilingual, community tools, code review development quality...
</aside>
</section>
<section>
<h2>Agenda</h2>
<ul>
<li>Behaviour driven development</li>
<li>Behat + Drupal</li>
<li>Quickstart your install</li>
<li>Speaking my language</li>
<li>Awesome tricks</li>
</ul>
<aside class="notes">
I want you to get out of here with a broad idea of what can be achieved and how easy it is. <br>
Is a extensible framework <br>
Is relevant because there is plans to be integrated into D8. <br>
</aside>
</section>
<section>
<section>
<h2>Behaviour driven development</h2>
<p>
Aka BDD
</p>
<aside class="notes">
It's a bit philosophical. <br>
Around the concept of behaviour. <br>
</aside>
</section>
<section>
<h2>What is BDD?</h2>
<img src="images/comic.jpg" alt="Questions" style="border:0; width: 600px;">
<aside class="notes">
It's about expectations on the different parts of people involved. <br>
Beta testers are important. Altough we don't have them.
</aside>
</section>
<section>
<h2>Get closer to the stakeholders</h2>
<p> We all use different languages. </p>
<aside class="notes">
Clients don't care about scope or budget so better speak bussines language. <br>
A solution for miscomunication. <br>
Get everyone together.
</aside>
</section>
<section>
<h2>Make development more conversational</h2>
<aside class="notes">
Create a common vocabulary between programmers, project managers, product owners, QA... <br>
Semantic tests.
</aside>
</section>
<section>
<h2>Make software that matters</h2>
<p>It's not just a cool thing to have it really adds bussines value.</p>
<aside class="notes">
You can check your application continously.
</aside>
</section>
<section>
<h2>Evolution</h2>
<ul>
<li>Unit tests: autotest your code.</li>
<li>TDD: Test goes first.</li>
<li>BDD: Design goes first.</li>
</ul>
<aside class="notes">
</aside>
</section>
</section>
<section>
<section>
<h2>Behat + Drupal</h2>
<img src="images/behatftw.png" alt="Questions" style="border:0; width: 600px;">
<aside class="notes">
</aside>
</section>
<section>
<h2>What is behat?</h2>
<p> BDD framework written in PHP.</p>
<ul>
<li>Uses gherkin as a business readable and domain specific language</li>
<li>Mink as a browser controller</li>
<li>Free software</li>
<li>Flexible (not only browsers)</li>
<li>Constitutes a challenge</li>
</ul>
<aside class="notes">
No dependencies because of php. <br>
Gherkin is a kind of cucumber.
<br>
Some browsers have js or different capabilities.
<br>
A challenge for the good of the development.
</aside>
</section>
<section>
<h2>Gherkin syntax</h2>
<p style="text-align: left;">
<code>
<strong>Feature:</strong> Banana Calculator <br>
In order to keep a stock of bananas <br>
As Bob the Banana merchant, <br>
I want a calculator that can add the amount of bananas so that I can know how many bananas I currently have <br>
<br>
<strong>Scenario:</strong> Add 2 banana amounts <br>
<strong>Given </strong>I have 3 Bananas <br>
<strong> When </strong>I add 5 Bananas <br>
<strong> Then </strong> I should have 8 Bananas <br>
</code>
</p>
<aside class="notes">
Structured language to describe features. <br>
keywords highlighted. <br>
.feature file <br>
multilingual. <br>
</aside>
</section>
<section>
<h2>Drawbacks</h2>
<ul>
<li>Slow.</li>
<li>Understanding of the domain.</li>
<li>Requires effort to make them robust.</li>
</ul>
<aside class="notes">
Even if you get a way to compile the semi natural language to something fast, you are still at a higher level. <br>
If a new button with the same name eg. "Send". your text will break.
</aside>
</section>
</section>
<section>
<section>
<h2>Quickstart your install</h2>
Behat is just a PHP library that can be installed with <strong>composer</strong>
<br>
<del><pre><code>
composer require behat/behat</code></pre></del>
<pre><code>
composer require drupal/drupal-extension='~3.1'
</code></pre>
<aside class="notes">
Little demo with a D8 standard install.
<br>
I'm not going into composer details.
</aside>
</section>
<section>
<h2>Initialize the skeleton</h2>
<pre><code>
vendor/bin/behat --init
</code></pre>
<aside class="notes">
Then we can write some features.
</aside>
</section>
<section>
<h2>behat.yml</h2>
<pre><code>
default:
suites:
default:
contexts:
- Drupal\DrupalExtension\Context\DrupalContext
extensions:
Behat\MinkExtension:
goutte: ~
base_url: http://example.org/ # Replace with your site's URL
Drupal\DrupalExtension:
blackbox: ~
</code></pre>
<aside class="notes">
Later you will add css selectors as regions to this file.
</aside>
</section>
<section>
<h2>Steps available</h2>
<pre><code>
vendor/bin/behat -di
</code></pre>
<ul>
<li>Given I am logged in as a user with the :role role</li>
<li>Given I am viewing a/an :type (content )with the title :title </li>
<li>Then I should see the error message( containing) :message</li>
<li>Then drush output should contain :output</li>
</ul>
<aside class="notes">
Then we can write some features. <br>
Just using natural phrases. <br>
There some steps that allow you to use css class. BAD <br>
</aside>
</section>
<section>
<h2>Execute the tests</h2>
<pre><code>
vendor/bin/behat
</code></pre>
<aside class="notes">
Simple! <br>
You can introduce in your task runner and receive a nice report.
</aside>
</section>
</section>
<section>
<section>
<h2>Speaking my language</h2>
<aside class="notes">
I want you to get out of here with a broad idea of what can be achieved and how easy it is.
</aside>
</section>
<section>
<h2>Behat and gherkin</h2>
<p> Translates each step in a PHP callback </p>
<aside class="notes">
When I run the banana example I get the code that I should write in the FeatureContext.php
</aside>
</section>
<section>
<h2>Speaking my language</h2>
<pre><code>
use Drupal\DrupalExtension\Context\RawDrupalContext;
use Behat\Behat\Context\SnippetAcceptingContext;
/**
* Defines application features from the specific context.
*/
class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext {
private $bananas
/**
* @Given /^I have (\d+) bananas$/
*/
public function iHaveBananas($b) {
$this->bananas = $b;
}
...
}
</code></pre>
<aside class="notes">
Regular expresions. <br>
Don't create phrases that are not meaningful to the user role. <br>
</aside>
</section>
<section>
<h2>Speaking my language</h2>
<pre><code>
/**
* @When /^I add (\d+) bananas$/
*/
public function iAddBananas($b) {
$this->bananas += $b;
}
</code></pre>
<aside class="notes">
</aside>
</section>
<section>
<h2>Speaking my language</h2>
<pre><code>
/**
* @Then /^I should have (\d+) bananas$/
*/
public function iShouldHaveBananas($b) {
assertEquals($b, $this->bananas);
}
</code></pre>
<aside class="notes">
</aside>
</section>
<section>
<h2>Command a browser - Mink</h2>
Fill out forms, click on buttons, check the output.
<aside class="notes">
Is just a controller. <br>
we have to add a driver. <br>
</aside>
</section>
<section>
<h2>Command a browser</h2>
<pre><code>
$session = $this->getSession();
$session->visit('http://drupal.org');
$session->getStatusCode();
$session->getCurrentUrl();
$page = $session->getPage();
$e = $page->find('css', li:nth-child(4) a);
$e->getText();
$e->getAttribute('href');
$e->click();
</code></pre>
<aside class="notes">
Session: just a tab. <br>
Page: the DOM. <br>
e: element <br>
</aside>
</section>
</section>
<section>
<section>
<h2>Awesome tricks</h2>
<ul>
<li>Test in any browser.</li>
<li>Debug tests</li>
<li>Nice reports</li>
</ul>
<aside class="notes">
We have the basics: <br>
A lot of steps meaningful for drupal <br>
The posibility of writting new steps. <br>
</aside>
</section>
<section>
<h2>Test with js enabled</h2>
<ul>
<li>Goutte driver is only doing curl request</li>
<li>Control when js is needed using @javascript tags in your scenarios</li>
<li>Cookies and headers</li>
<li>Manipulate the page</li>
<li>Selenium, phantomjs</li>
</ul>
<aside class="notes">
Autocomplete
</aside>
</section>
<section>
<h2>Test in any browser</h2>
<ul>
<li>Different js implementations</li>
<li>Screenshots</li>
</ul>
<aside class="notes">
selenium web driver <br>
headless <br>
visual regressions. <br>
The definitions change: for example I cannot fill invisible form items. <br>
</aside>
</section>
<section>
<h2>Anything is possible</h2>
<pre><code>
/**
* @Given /^I switch to the first iframe$/
*/
public function iSwitchToTheFirstIframe() {
$javascript = <<<JS
(function(){
var iframes = document.getElementsByTagName('iframe');
var f = iframes[0];
f.id = "no_name_iframe";
})()
JS;
$this->getSession()->executeScript($javascript);
$this->getSession()->switchToIFrame('no_name_iframe');
}
</code></pre>
<aside class="notes">
Not only command the browser, execute js.
</aside>
</section>
<section>
<h2>Debugging: Then I break.</h2>
<p>
<img src="images/break.gif" alt="Samuel" style="border:0; width: 600px;">
</p>
<aside class="notes">
Stops the test.
</aside>
</section>
<section>
<h2>Debugging - screenshot</h2>
<img src="images/screenshot.jpg" alt="Take a screenshot" style="border:0; width: 600px;">
<aside class="notes">
</aside>
</section>
<section>
<h2>HTML reports</h2>
<img src="images/htmlreport.png" alt="HTML report" style="border:0; width: 600px;">
<br>
<a href="https://github.com/dutchiexl/BehatHtmlFormatterPlugin">https://github.com/dutchiexl/BehatHtmlFormatterPlugin</a>
<aside class="notes">
You can get the stakeholders involved. <br>
Maybe the product owner knows what changed.
</aside>
</section>
</section>
<section>
<section>
<h2>Behat and drupal core.</h2>
[Meta] Use Behat for validation testing <a href="https://www.drupal.org/node/2232271">https://www.drupal.org/node/2232271</a>
<br>
JS testing have been commited recently.
<aside class="notes">
A different phantomjs driver has been included.
<br>
</aside>
</section>
</section>
<section>
<section>
<h2>It's so easy!</h2>
<p>Very good documentation.</p>
<aside class="notes">
One download and one command. <br>
Don't go full BDD. <br>
The most important pages. <br>
Use only the steps available. <br>
</aside>
</section>
</section>
<section>
<h2>Interesting references</h2>
<ul>
<li><a href="http://ymbra.com/blog/how-get-started-behat">Introdution to behat by Merce (coworker at Ymbra)</a></li>
<li><a href="http://metadrop.net/dev/behat-3x-y-drupal-cambios-respecto-behat-2x">Migrate from behat 2 to 3 by sanzante@metadrop</a></li>
<li><a href="https://github.com/jhedstrom/drupalextension">Behat Drupal Extension</a></li>
<li><a href="http://rodrigoaguilera.github.io/talk_behat"> Slides: http://rodrigoaguilera.github.io/talk_behat</a></li>
<li><a href="https://www.youtube.com/watch?v=0F7-Rr4s9is">Behat intro from a symfony dev</a></li>
</ul>
</section>
<section>
<h2>Questions</h2>
<p>
<img src="images/questions.png" alt="Questions" style="border:0; width: 600px;">
</p>
<aside class="notes">
</aside>
</section>
<section style="text-align: left;">
<h1>THE END</h1>
<p>
Thank you. <br>
- <a href="http://docs.behat.org">http://docs.behat.org</a> <br>
</p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true }
]
});
</script>
</body>
</html>