-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
654 lines (563 loc) · 23.5 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
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>DrupalDay Bologna 2015</title>
<meta name="description" content="">
<meta name="author" content="Francesco Sardara">
<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="vendor/reveal.js/css/reveal.css">
<link rel="stylesheet" href="vendor/reveal.js/css/theme/moon.css" id="theme">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="vendor/reveal.js/lib/css/zenburn.css">
<link rel="stylesheet" href="assets/style.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 ) ? 'vendor/reveal.js/css/print/pdf.css' : 'vendor/reveal.js/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="vendor/reveal.js/lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<section data-state="intro"></section>
<section>
<h2>Mantenere una distribuzione Drupal attraverso test coverage</h2>
<h3>Paddle case study</h3>
<p style="margin-top: 80px; font-size: 80%;">
<a href="https://github.com/brummbar/drupal-day-2015">https://github.com/brummbar/drupal-day-2015</a>
</p>
</section>
<section>
<section>
<h1>About me</h1>
</section>
<section>
<h2>Francesco Sardara</h2>
<img src="assets/images/me.jpg" alt="Me" width="300" style="float: left; margin-right: 50px">
<div class="align-left" style="padding-top: 50px;">
<p>Backend e frontend</p>
<p style="padding-top: 50px;">Email: francesco.sardara@kanooh.be</p>
<p>D.o: Sardara</p>
</div>
</section>
<section>
<h2>Per chi lavoro</h2>
<img src="assets/images/one.png" alt="ONE Agency" style="margin-right: 200px;">
<img src="assets/images/paddle.png" alt="Paddle">
</section>
</section>
<section>
<section>
<h2>Cosa è Paddle</h2>
<img src="assets/images/paddle_big.png" alt="Paddle">
</section>
<section>
<img src="assets/images/company-fusion.png" alt="Cosa è Paddle" style="background-color: #fff;">
<aside class="notes">
Esn: full service communication agency<br>
ONE: web dev agency specialized in Drupal
</aside>
</section>
<section>
<h2>Flemish government</h2>
<p>Framework contract</p>
<ul>
<li>Unico referente per sito web, hosting e supporto;</li>
<li>frontend che segue le specifiche di branding del governo Fiammingo;</li>
<li>focus sulla gestione dei contenuti (revisioni, workflow);</li>
<li>usabilità del backend per utenti non esperti;</li>
<li>commenti, multilingua, contatti, quiz, rss, newsletter, protected pages.</li>
</ul>
</section>
<!--<section>
<h2>Come mantenere una codebase:</h2>
<ul>
<li class="fragment">ampia</li>
<li class="fragment">"vecchia"</li>
<li class="fragment">"nuova" per alcuni dev</li>
</ul>
<h1 class="fragment">test coverage</h1>
</section>-->
</section>
<section>
<section>
<h1>Workflow di lavoro</h1>
</section>
<section>
<p>Sprint di 2 settimane</p>
<div class="fragment">
<p>↓</p>
<p>Soft release</p>
</div>
<div class="fragment">
<p>↓</p>
<p>Hard release</p>
<p>Rilascio in produzione</p>
</div>
</section>
<section>
<h3>Organizzazione dello sprint</h3>
<ul class="fragment">
<li>Open/Reopened</li>
<li>Development</li>
<li>Testing</li>
<li>QA</li>
<li>UAT</li>
</ul>
</section>
<section>
<h3>Anatomia di un ticket</h3>
<ul>
<li>User story / descrizione bug</li>
<li>UAT steps</li>
<li>Definition of done</li>
</ul>
</section>
<section>
<h3>Definition of done</h3>
<ul style="font-size: 80%;">
<li>Functionally complete</li>
<li>Automated tests cover UAT instructions</li>
<li>Automated Simpletest tests passing within the last 24h</li>
<li>Automated Selenium tests passing within the last 24h</li>
<li>Working upgrade path from the last release in place</li>
<li>...</li>
</ul>
</section>
<section>
<h3>Automated tests</h3>
<ul>
<li>Simpletest e Selenium</li>
<li>Shoov.io / Webdrivercss</li>
<li>
Eseguiti su server tramite Jenkins CI
<ul>
<li>Esecuzioni giornaliere automatiche</li>
<li>Esecuzioni manuali per ticket</li>
</ul>
</li>
<li>Esecuzione remota su Browserstack</li>
</ul>
<aside class="notes">
Citare coding standards Jenkins job.
</aside>
</section>
<section>
<img src="assets/images/dothraki.jpg" alt="Dothraki">
</section>
</section>
<section>
<section>
<h1>Selenium</h1>
<ul>
<li>automatizzazione di test su applicazioni web</li>
<li>ampiamente supportato in svariati linguaggi</li>
<li>Selenium IDE e Webdriver</li>
</ul>
</section>
<section>
<h2>Cosa testiamo in Selenium</h2>
<ul>
<li>funzionalità personalizzate</li>
<li>integrazioni tra moduli</li>
<li>funzionalità Javascript</li>
<li>regressioni</li>
</ul>
</section>
<section>
<h2>Qualche numero</h2>
<ul>
<li class="fragment">746 test</li>
<li class="fragment">10966 asserzioni</li>
<li class="fragment">tempo di esecuzione di <span class="fragment">18 ore</span></li>
<li class="fragment">richiedono 2/3 del tempo di sviluppo</li>
</ul>
</section>
</section>
<section>
<section>
<h1>Page object pattern</h1>
</section>
<section>
<h2>Punti chiave</h2>
<ul>
<li class="fragment">riduzione della duplicazione del codice</li>
<li class="fragment">facilità nell’aggiornare la relativa classe se gli elementi della pagina cambiano</li>
<li class="fragment">possibilità di sfruttare appieno i meccanismi di ereditarietà</li>
</ul>
</section>
<section>
<h2>Regole</h2>
<ul>
<li class="fragment">solo la classe deve contenere XPath / selettori CSS relativi all’elemento</li>
<li class="fragment">nessuna assertion deve essere fatta all’interno della classe</li>
</ul>
</section>
<section>
<h1>Page object pattern in Paddle</h1>
</section>
<section>
<h3>Struttura cartelle</h3>
<img src="assets/images/paddle-folder-struct.png" alt="Paddle folder structure" height="450">
</section>
<section>
<img src="assets/images/paddle-folder-pages.png" alt="Paddle pages folder" width="500">
</section>
<section>
<h2>Anatomia di una classe Page Object</h2>
</section>
<section>
<p>Il metodo costruttore contiene sempre una referenza a Webdriver e all'oggetto Selenium.</p>
<pre class="php"><code class="hljs" data-trim>
/**
* Construct a new GlossaryDefinitionTableRow.
*
* @param WebDriverTestCase $webdriver
* The Selenium web driver test case.
* @param \PHPUnit_Extensions_Selenium2TestCase_Element $element
* The webdriver element of the definition table row.
*/
public function __construct(WebDriverTestCase $webdriver, $element)
{
parent::__construct($webdriver);
$this->element = $element;
}
</code></pre>
</section>
<section>
<p>Tutte le proprietà che rappresentano altri Page Object sono gestite tramite magic get.</p>
<pre class="php"><code class="hljs" data-trim>
/**
* {@inheritdoc}
*/
public function __get($name)
{
switch ($name) {
case 'saveButton':
return $this->element->byXPath('.//input[contains(@id, "edit-save")]');
break;
case 'definition':
return new Text($this->webdriver, $this->element->byName('definition'));
break;
case 'description':
return new Wysiwyg($this->webdriver, 'edit-field-glossary-description-und-0-value');
break;
}
throw new FormFieldNotDefinedException($name);
}
</code></pre>
</section>
<section>
<h3>Perché usare __get() ?</h3>
<ul>
<li class="fragment">Legacy code</li>
<li class="fragment">Separazione dalle proprietà</li>
<li class="fragment">
Linearità di lettura
<pre class="php" style="min-width: 850px;"><code class="hljs" data-trim>
$this->configurePage->go();
$this->configurePage->contextualToolbar->buttonAdd->click();
$modal->form->definition->fill($title);
$modal->form->description->setBodyText($description);
$modal->form->saveButton->click();
$modal->waitUntilClosed();
</code></pre>
</li>
</ul>
</section>
</section>
<section>
<section>
<h1>Esempio di test case</h1>
<p><a href="phpstorm://open?file=/Users/francesco/Projects/web/paddle/selenium/tests/Kanooh/Paddle/App/Glossary/GlossaryTest.php&line=34">GlossaryTest.php</a></p>
<p><a href="phpstorm://open?file=/Users/francesco/Projects/web/paddle/selenium/tests/Kanooh/Paddle/App/Glossary/GlossaryTest.php&line=298">testGlossaryDefinitionHighlighting</a></p>
<aside class="notes">PRO tip: use PHPStorm to run tests... and debug them!</aside>
</section>
<section data-background-video="assets/videos/selenium-run-browserstack.mp4"></section>
<section>
<h2>Risultato del test</h2>
<img class="fragment" src="assets/images/fail.gif" alt="Fail" height="500">
</section>
<section>
<img class="fragment" src="assets/images/tests-expected.png" alt="Expected results" width="338">
<img class="fragment" src="assets/images/tests-reality.png" alt="Real results" width="338">
</section>
</section>
<section>
<section>
<h1>Sopravvivere ai test</h1>
<p>Approcci e best practices</p>
</section>
<section>
<h2>Random Failing Tests</h2>
<p>Per RFT si indicano quei test che senza nessun cambiamento nel codice o nei dati di test(*),
il loro risultato non è costante.</p>
<p class="fragment">Cause comuni:</p>
<ul>
<li class="fragment">differenze hardware</li>
<li class="fragment">dati di test</li>
</ul>
</section>
<section>
<h2>implicit e explicit waits</h2>
<p>Il tempo di attesa implicito rappresenta per quanto tempo Webdriver deve interrogare il DOM
in attesa di trovare un elemento se esso non è disponibile immediatamente.</p>
<p>Il tempo di attesa esplicito rappresenta per quanto tempo Webdriver deve aspettare una certa
condizione prima di proseguire con l'esecuzione.</p>
</section>
<section>
<h3>Implicit wait</h3>
<pre class="php"><code class="hljs" data-trim>
// Add a new definition.
$this->configurePage->contextualToolbar->buttonAdd->click();
$modal = new GlossaryDefinitionModal($this);
$modal->form->definition->fill('The awesome definition');
</code></pre>
<img class="fragment" src="assets/images/no-wait-failure.png" alt="No wait RFT" width="900">
</section>
<section>
<h3>Explicit wait</h3>
<pre class="php"><code class="hljs" data-trim>
// Add a new definition.
$this->configurePage->contextualToolbar->buttonAdd->click();
$modal = new GlossaryDefinitionModal($this);
$modal->waitUntilOpened();
$modal->form->definition->fill('The awesome definition');
</code></pre>
<pre class="php fragment"><code class="hljs" data-trim>
public function waitUntilOpened()
{
$callable = new SerializableClosure(...);
$this->webdriver->waitUntil($callable, $this->timeout);
}
</code></pre>
</section>
<section>
<h2>Randomizzare i dati di test</h2>
<div class="fragment" style="float: left; width: 45%; font-size: 80%">
<p class="align-left" style="padding-left: 30px; color: green; font-weight: 700;">Pro</p>
<ul>
<li>Evitare parzialmente "collisioni" tra contenuti</li>
<li>Trovare casi limite</li>
<li>Simulare un vero utilizzo del sistema</li>
</ul>
</div>
<div class="fragment" style="margin-left: 5%; float: left; width: 45%; font-size: 80%">
<p class="align-left" style="padding-left: 30px; color: red; font-weight: 700;">Contro</p>
<ul>
<li>La randomizzazione rende il test non completamente prevedibile</li>
</ul>
</div>
<aside class="notes">
Caso limite: autocomplete transformati da SnowballPorterFilter <br>
Caso limite contro: regione random nei test dei pannelli
</aside>
</section>
<section>
<h3>L'approccio di Paddle</h3>
<ul>
<li class="fragment">La generazione dei contenuti è randomizzata.</li>
<li class="fragment">I contenuti vengono lasciati intatti a meno che la loro presenza non complichi la realizzazione del test.</li>
</ul>
<aside class="notes">Atoms e il problema delle pagine multiple.</aside>
</section>
</section>
<section>
<section>
<h1>Sopravvivere ai test (reprise)</h1>
<p>Approcci in Paddle</p>
</section>
<section>
<h3>Ckeditor</h3>
<pre class="php fragment"><code class="hljs" data-trim>
/**
* Sets the body text.
*
* @param string $text
* The text to enter in the body.
*/
public function setBodyText($text)
{
$this->webdriver->byId('cke_' . $this->editorId);
$this->webdriver->execute(
array(
'script' => "CKEDITOR.instances['{$this->editorId}'].setData('" . $text . "');",
'args' => array(),
)
);
}
</code></pre>
</section>
<section>
<h3>Ajax callbacks</h3>
<pre class="php fragment"><code class="hljs" data-trim>
// ...
$form['list_id'] = array(
'#type' => 'select',
'#title' => t('List'),
'#required' => TRUE,
'#ajax' => array(
'callback' => 'mailchimp_campaign_list_segment_callback',
),
);
// ...
</code></pre>
</section>
<section>
<pre class="php"><code class="hljs" data-trim>
/**
* Marks the element as if it is waiting for AJAX callbacks.
*
* @see \Kanooh\Paddle\Pages\Element\Form\AutoCompletedText::markAsWaitingForAutoCompleteResults()
*/
public function markAsWaitingForAjaxCallback(\PHPUnit_Extensions_Selenium2TestCase_Element $element)
{
$this->webdriver->execute(
array(
'script' => "arguments[0].className += ' progress-disabled';",
'args' => array($element->toWebDriverObject()),
)
);
}
</code></pre>
</section>
<section>
<h2>Mastering the stale</h2>
<pre class="php fragment"><code class="hljs" data-trim>
// ...
$form = $image_pane_type->getForm();
$form->showCaption->check();
// Submit the form and reload the modal.
$form->submit();
// Test something else.
$form->captionTextArea->fill('Oooops');
// ...
</code></pre>
<img class="fragment" src="assets/images/stale-failure.png" alt="Stale" width="900">
</section>
<section>
<h2>Exploiting the stale</h2>
<pre class="php fragment"><code class="hljs" data-trim>
// Waits until the current page is loaded.
public function waitUntilPageIsLoaded()
{
$body = $this->bodyElement;
$webdriver = $this->webdriver;
$callable = new SerializableClosure(
function () use ($body, $webdriver) {
try {
$body->click();
} catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) {
return true;
}
}
);
$this->webdriver->waitUntil($callable, $this->webdriver->getTimeout());
$this->webdriver->waitUntilElementIsDisplayed('//body');
}
</code></pre>
</section>
</section>
<section>
<section>
<h1>Improving Selenium results</h1>
</section>
<section>
<h3>Ripetizioni multiple per evitare l'introduzione di RFT</h3>
<pre class="sh"><code class="hljs" data-trim>
$ base_url=http://paddle.dev ./vendor/bin/phpunit --repeat=3 \
tests/Kanooh/Paddle/App/ContactPerson/EnableDisableTest.php
</code></pre>
</section>
<section>
<h3>Riconoscere le RFT</h3>
<pre class="sh"><code class="hljs" data-trim>
$ ./vendor/bin/phpunit --repeat=2 --only-repeat-failed tests/
</code></pre>
</section>
<section>
<h3>Velocizzare l'esecuzione</h3>
<ul>
<li>esecuzione in parallelo dei test</li>
<li>sfruttare drupal/drupal-driver per rimuovere interazioni browser non necessarie</li>
</ul>
</section>
</section>
<section>
<section>
<h1>Visual regression</h1>
<h3>Webdrivercss e shoov.io</h3>
</section>
<section>
<h2>Webdrivercss</h2>
<p>Tool di automatizzazione per test di visual regression per WebdriverIO.</p>
<aside class="notes">
<p>WebdriverIO è Selenium binding per Node.js</p>
<p>Stato attuale "unstable"</p>
</aside>
</section>
<section>
<h2>Shoov.io</h2>
<p>Tool di visual regression e live monitoring.</p>
<ul>
<li class="fragment">Wrapper per Webdrivercss</li>
<li class="fragment">Headless Drupal per lo storage degli screenshot</li>
<li class="fragment">Angular.js web-app per il confronto visuale</li>
<li class="fragment">Integrazione con Github (login, commits, pull request)</li>
<li class="fragment">Gratuito (?)</li>
</ul>
</section>
<section>
<h3>L'approccio di Paddle al VR</h3>
<p><a href="phpstorm://open?file=/Users/francesco/Projects/web/visual-regression/tests.config.json&line=1">Configuration</a></p>
<p><a href="phpstorm://open?file=/Users/francesco/Projects/web/visual-regression/test/test.js&line=45">Single test</a></p>
<p style="margin-top: 80px; font-size: 80%;"><a href="https://github.com/brummbar/visual-regression">https://github.com/brummbar/visual-regression</a></p>
</section>
</section>
<section>
<section>
<h1>Q&A</h1>
</section>
<section>
Per domande o suggerimenti, scrivetemi <a href="#">francesco.sardara@kanooh.be</a>
</section>
<section>
<h1>Grazie per l'attenzione.</h1>
</section>
</section>
<section data-state="outro"></section>
</div>
</div>
<script src="vendor/reveal.js/lib/js/head.min.js"></script>
<script src="vendor/reveal.js/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: 'vendor/reveal.js/lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'vendor/reveal.js/plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'vendor/reveal.js/plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'vendor/reveal.js/plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'vendor/reveal.js/plugin/zoom-js/zoom.js', async: true },
{ src: 'vendor/reveal.js/plugin/notes/notes.js', async: true }
]
});
</script>
</body>
</html>