/
index.html
528 lines (468 loc) · 16.9 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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>TDD</title>
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css">
<link rel="stylesheet" href="css/styles.css">
<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>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>Test-Driven Development</h1>
<h3></h3>
<img src="img/tim.jpeg" width="20%"/>
<img src="img/wouter.jpeg" width="20%"/>
<p>
<small>
<span style="font-size: 11pt;">
Tim Schraepen & Wouter Groeneveld<br/>
30/01/2017<br/>
<a href="https://wgroeneveld.github.io/tdd-course/">https://wgroeneveld.github.io/tdd-course/</a>
</span>
</small>
</p>
</section>
<section>
<h4>Pre-requirements: installaties</h4>
<h5>PHP</h5>
<ul>
<li><a href="http://php.net/" target="_blank">http://php.net/</a></li>
<li><a href="https://phpunit.de/manual/current/en/installation.html" target="_blank">https://phpunit.de/manual/current/en/installation.html</a></li>
</ul>
<pre><code>
echo @php "%~dp0phpunit.phar" %* > phpunit.cmd
</code></pre>
<h5>Java</h5>
<ul>
<li><a href="https://www.jetbrains.com/idea/download/download-thanks.html?code=IIC" target="_blank">https://www.jetbrains.com/idea/#chooseYourEdition</a></li>
<li><a href="http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html" target="_blank">http://www.oracle.com/technetwork/java/javase/downloads/</a></li>
</ul>
<h5>Een editor</h5>
<a href="https://code.visualstudio.com/" target="_blank">VSCode</a> of
<a href="https://www.sublimetext.com/" target="_blank">Sublime</a> of
<a href="https://atom.io/" target="_blank">Atom</a>
</section>
<section>
<h4>Introductie</h4>
<section>
<h4>Wouter</h4>
Prato, brood bakken, PXL, ...
</section>
<section>
<h4>Tim</h4>
Cegeka, LeanCoffee Leuven, PXL, ...
</section>
<section>
<h4>Doel</h4>
<ul>
<li>Jullie zelfzeker maken in TDD</li>
<li>Zodat jullie dit kunnen overbrengen aan jullie leerlingen</li>
<li>Door middel van TDD in jullie lessen te verwikkelen</li>
</ul>
</section>
<section style="font-size: 20pt;">
<table>
<tbody>
<tr><td>9:10</td><td>Laptop setup double check</td></tr>
<tr><td>9:20</td><td>Unit Testing</td></tr>
<tr><td>10:00</td><td>Oefening: Basic Unit testing (<strong>JS</strong>)</td></tr>
<tr><td>11:00</td><td>Unit Testing en TDD</td></tr>
<tr><td>11:10</td><td>Oefening: Legacy Code 1 (<strong>PHP</strong>)</td></tr>
<tr><td>11:30</td><td>Code Retreat!</td></tr>
<tr><td>12:00</td><td>Lunch</td></tr>
<tr><td>13:30</td><td>Soorten testen</td></tr>
<tr><td>14:00</td><td>Oefening: Integrated TDD (<strong>Java</strong>)</td></tr>
<tr><td>16:50</td><td>Wat hebben we geleerd?</td></tr>
</tbody>
</table>
</section>
</section>
<section>
<section>
<h2>TDD Deel 1: <br/>Unit testing</h2>
<img src="img/nunit.png"/>
</section>
<section>
<h2>Wat is Unit Testing</h2>
<ul>
<li>Test Harnas<br/> bvb. JUnit, MSTest</li>
<li>Assertion Framework <br/> bvb. <span class="inlinecode">Assert.That(expected).IsEqualTo(actual);</span></li>
<li>TDD</li>
</ul>
</section>
</section>
<section>
<section>
<h4>Waarom unit testen?</h4>
<img src="img/waaromunittesten.jpg" />
</section>
<section>
<h4>Waarom unit testen?</h4>
<ul>
<li><strong>Early Feedback!</strong></li>
<li>Denk in code vanuit API standpunt</li>
<li>Makkelijk voor pair om te volgen</li>
<li>Alle mogelijke paden gedekt</li>
<li>Documentatie</li>
</ul>
</section>
<section data-background="img/speculaas.jpg">
<blockquote class="darker">
<h2>Oefening: basic testing in <strong>Javascript</strong></h2>
<h4>makkelijk genoeg voor alle niveau's</h4>
<a href="https://classroom.github.com/assignment-invitations/18edaf0f50a1fafb25c9bbb5fdd8f7eb">Oefening 1: speculaas</a>
</blockquote>
</section>
<section>
<h4>Unit testing in JS</h4>
<p>
<a href="http://jasmine.github.io/2.5/introduction.html" target="_blank"><img src="img/jasmine-horizontal.png" alt="jasmine logo" /></a>
</p>
<pre><code>
describe("A suite", function() {
it("contains spec with an expectation", function() {
expect(true).toBe(true);
});
});
</code></pre>
Beschrijft <strong>gedrag</strong><br/>
C# equiv.: <span class="inlinecode">Assert.That(true).IsEqualTo(true);</span>
</section>
<section>
<h4>Unit testing in JS</h4>
<p>
Hoe runnen? <span class="inlinecode">runtests.html</span><br/>
<img src="img/howtorun_js.png" alt="how to run JS tests" width="70%"/>
</p>
</section>
</section>
<section>
<section>
<h4>Eigenschappen van een goede test</h4>
<ul>
<li>Ontdek sneller bugs</li>
<li>Leesbaar</li>
<li>Geautomatiseerd</li>
<li>Snel & gefocuset (test 1 ding)</li>
<li>Herhaalbaar</li>
<li>Volgorde onafhankelijk</li>
<li>Losgekoppeld van de implementatie</li>
<li>Productie code makkelijker wijzigbaar (aanpasbaarheid en design)</li>
</ul>
</section>
<section>
<h4>Geautomatiseerd</h4>
<img src="img/teamcity.png" style="width: 60%" /><br/>
<a href="https://travis-ci.org/" target="_blank">Travis CI org. + GitHub live demo</a>
</section>
<section>
<h4>Geautomatiseerd: build lifecycle</h4>
<img src="img/devopsProcess.png" style="width: 125%" /><br/>
</section>
<section>
<h4>Living Documentation</h4>
<img src="img/livingdocumentation.png"/>
</section>
<section>
<h4>NIET Losgekoppeld van implementatie!</h4>
<script src="https://gist.github.com/Sch3lp/a712cb3bc2098253a2187d3ad26da431.js"></script>
</section>
</section>
<section>
<section>
<h4>Test Driven Development (TDD)</h4>
<img src="img/tdd.png" width="60%"/>
</section>
<section>
<h4>En wat is refactoring?</h4>
<blockquote>Structuur veranderen,<br/> zonder inhoud te wijzigen!</blockquote>
<p style="font-size: 20pt; margin-top: 40px;">
Voel jij je veilig genoeg zonder testen?
</p>
</section>
</section>
<section>
<section data-background="img/abugslife.jpg">
<h4>TDD: "bugfix" edge case</h4>
Live Demo in <strong>C#</strong>
</section>
<section>
<h4>Unit testing in C#</h4>
<p>
<a href="https://github.com/nunit/docs/wiki" target="_blank"><img src="img/nunit-logo.png" alt="nunit logo" /></a>
</p>
<pre><code>
[TestFixture]
public class MyTestClass {
[Test]
public void SomeMethodShouldReturnTrueIfSomeCondition() {
var result = SomeMethod();
Assert.That(result, Is.EqualTo(expected));
}
}
</code></pre>
</section>
<section>
<h4>Unit testing in C#</h4>
<p>
Gebruik tools van IDE:<br/>
<img src="img/howtorun_csharp.png" alt="how to run CSharp tests" width="70%"/>
</p>
<p>
<a href="https://www.jetbrains.com/resharper/documentation/documentation.html" target="_blank">Resharper Documentation</a>
</p>
</section>
</section>
<section>
<section>
<h4>Oefening: Legacy code in <strong>PHP</strong></h4>
<a href="https://classroom.github.com/assignment-invitations/cb292bbd37bf63d28ef5525262986f74">Legacy Code oefening</a>
</section>
<section>
<img src="img/working.jpg"
width="45%"
alt="my code is working, I don't know why?"/>
</section>
<section>
<h4>Unit Testing in PHPUnit</h4>
<p><a href="https://phpunit.de/manual/" target="_blank">https://phpunit.de/manual/</a></p>
<pre><code>
public function testStub()
{
$mock = $this->createMock(SomeClass::class);
$mock->method('doSomething')->willReturn('foo');
$this->assertEquals('foo', $mock->doSomething());
}
</code></pre>
</section>
<section>
<h4>Unit Testing in PHP</h4>
<p>
Hoe runnen? <br/>
<span class="inlinecode">phpunit [dir]</span><br/>
<span class="inlinecode">phpunit dir/testfile.php</span><br/>
<pre style="background-color: #555555; padding: 20px; border: 1px solid #FFFFFF;">
PHPUnit 4.3.5 by Sebastian Bergmann.
.......................
Time: 105 ms, Memory: 2.75Mb
OK (23 tests, 25 assertions)
</pre>
</p>
</section>
</section>
<section>
<section data-background="img/mob_programming.jpg">
</section>
<section>
<h4>Code Retreat oefening</h4>
<a href="http://github.com/SoftwareSandbox/gdcr16-java">Java</a><br/>
<a href="http://github.com/SoftwareSandbox/gdcr16-js">JavaScript</a><br/>
<a href="http://github.com/SoftwareSandbox/gdcr16-csharp">C# .NET</a><br/>
<a href="http://github.com/SoftwareSandbox/gdcr16-php">PHP</a><br/>
<p>
» <strong><a href="http://oss.jahed.io/agility/timer.html" target="_blank">Mob Timer</a></strong>
</p>
</section>
<section style="font-size: 20pt;">
<ul>
<li>Write exactly one new test. It should be the smallest test which seems to point in the direction of a solution</li>
<li>Run the test to make sure it fails</li>
<li>Make the test from (1) pass by writing the least amount of implementation code you can <strong>IN THE TEST METHOD</strong>.</li>
<li>Refactor to remove duplication or otherwise as required to improve the design. Be strict about the refactorings. Only introduce new abstractions (methods, classes, etc) when they will help to improve the design of the code.</li>
</ul>
<em>Specifically</em>:
<ul>
<li><strong>ONLY</strong> Extract a new method if there is sufficient code duplication in the test methods. When extracting a method, initially extract it to the test class (don't create a new class yet).</li>
<li><strong>ONLY</strong> create a new class when a clear grouping of methods emerges and when the test class starts to feel crowded or too large.</li>
</ul>
Repeat the process by writing another test (go back to step #1).
</section>
</section>
<section>
<section>
<h4>Soorten testen</h4>
<img src="img/testniveaus.png"/>
<p> </p>
</section>
<section>
<h4 style="background-color: green">Unit Testing</h4>
<ul>
<li>Onafhankelijk van externen (db, webservice, ...)</li>
<li>Snel!</li>
<li>Véél testen</li>
<li>Test Happy Path & Edge Cases</li>
<li>"Actieve vijand van de code"</li>
</ul>
</section>
<section>
<h4 style="background-color: orange">Integration Testing</h4>
<ul>
<li>Test geïntegreerd met externen (db, webservice, ...)</li>
<li>Test integratie <strong>twee verschillende lagen</strong></li>
<li>Trager dan unit tests</li>
<li>Minder test cases</li>
</ul>
</section>
<section>
<h4 style="background-color: orange">Integration Testing</h4>
Test doubles<br/>
<img src="img/testdouble.jpg" width="75%">
</section>
<section>
<h4 style="background-color: orange">Integration Testing</h4>
<p>
<ul>
<li>Mocks</li>
<li>Stubs</li>
<li>Spies</li>
</ul>
</p>
<p>
Details: zie <a href="http://martinfowler.com/articles/mocksArentStubs.html" target="_blank">Mocks aren't stubs</a> by Martin Fowler.
</p>
</section>
<section>
<h4 style="background-color: red">End to End Testing</h4>
<ul>
<li>Test hele applicatie!</li>
<li>niet alle limieten</li>
<li>traag, moeilijker onderhoudbaar</li>
<li>Test integratie <strong>alle</strong> lagen</li>
</ul>
</section>
<section>
<h4>Voorbeeldje/demo</h4>
Eventueel mee volgen in <br/>
<a href="https://github.com/wgroeneveld/tdd-course/tree/gh-pages/labs/integrationtest-livedemo" target="_blank">tdd-course/labs/integrationtest-livedemo</a>
</section>
</section>
<section>
<section>
<h4>Oefening: Integrated TDD met <strong>Java</strong></h4>
<a href="https://classroom.github.com/assignment-invitations/dee34e87efca3b3aa1fa5e518c4d6759">En nu is het aan jullie!</a>
<p>
Om jullie te helpen om sneller te ontwikkelen:<br/>
<a href="https://github.com/Sch3lp/ProductivityWithShortcuts">Shortcuts cursus met IntelliJ</a><br/>
<a href="https://www.jetbrains.com/resharper/docs/ReSharper_DefaultKeymap_VSscheme.pdf">ReSharper cheat sheet keymap</a>
</p>
</section>
<section>
<h4>Unit Testing in Java</h4>
<p>
<a href="http://junit.org/junit4/javadoc/latest/" target="_blank">http://junit.org/junit4/javadoc/latest/</a><br/>
<a href="http://joel-costigliola.github.io/assertj/" target="_blank">http://joel-costigliola.github.io/assertj/</a>
</p>
<pre><code>
import static org.assertj.core.api.Assertions.assertThat;
@Test
public void methodShouldReturnTrueIfBehaviourCorrect()
{
bool result = method();
assertThat(result).isTrue();
}
</code></pre>
</section>
<section>
<h4>Unit Testing in Java</h4>
<p>
Hoe runnen? Gebruik tools van IDE:<br/>
<img src="img/howtorun_java.png" alt="How to run java tests"/>
</p>
</section>
</section>
<section>
<section>
<h2>Resources</h2>
<span style="font-size: 20pt;">
<ul>
<li><a href="http://butunclebob.com/files/downloads/Bowling%20Game%20Kata.ppt">Bowling Game Kata</a> (Uncle Bob)</li>
<li><a href="https://github.com/wgroeneveld/tdd-course">https://github.com/wgroeneveld/tdd-course</a></li>
<li><a href="http://codemanship.co.uk/parlezuml/blog/?postid=987">Classic TDD or 'London School'?</a></li>
<li><a href="http://www.inf.fu-berlin.de/inst/ag-se/teaching/K-CCD-2014/Clean-Code-summary.pdf">The Essence of clean code</a></li>
<li><a href="https://www.codeschool.com/">Code School</a>, <a href="https://www.codewars.com/">Code Wars</a> en anderen</li>
</ul>
</span>
</section>
<section>
<h4>Boeken</h4>
<p>Growing Object-Oriented Software Guided by Tests</p>
<img src="img/growing.jpg"/>
</section>
<section>
<h4>Boeken</h4>
<p>Clean Code</p>
<img src="img/cleancode.jpg" width="40%" />
</section>
<section>
<h4>Boeken</h4>
<p>Working Effectively With Legacy Code</p>
<img src="img/legacycode.jpg"/>
</section>
</section>
<section data-background="img/watgeleerd.jpg">
<h2>Wat hebben we geleerd?</h2>
<section>
<blockquote class="darker">
<h2>Tim en Wouter zijn BAZEN</h2>
</blockquote>
</section>
<section>
<blockquote class="darker">
Test Driven Development zorgt voor:<br/>
<br/>
<ul>
<li>Beter design (loose coupling, single responsibility)</li>
<li>Leesbare code</li>
<li>Een vangnet voor Legacy code</li>
</ul>
</blockquote>
</section>
<section>
<blockquote class="darker">
Test Driven Development is...<br/>
<br/>
<ul>
<li>...helemaal niet zo scary!</li>
<li>...toegankelijk voor studenten</li>
<li>...zoals we het vandaag gezien hebben overdraagbaar op studenten</li>
</ul>
</blockquote>
</section>
</section>
<section data-background="img/thatsall.png">
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
history: true,
// More info https://github.com/hakimel/reveal.js#dependencies
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
document.querySelectorAll('code').forEach(function(block) {
block.className = block.className + ' php';
});
</script>
</body>
</html>