-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
352 lines (290 loc) · 10.6 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
<!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>Mutation testing with Pitest</title>
<link rel='stylesheet' href='css/reveal.css'>
<link rel='stylesheet' href='css/theme/white.css'>
<link rel='stylesheet' href='css/override.css'>
</head>
<body>
<div class='reveal'>
<div class='slides'>
<section><h2>Do you trust your <span class='pitest-pink'>unit tests</span>?</h2></section>
<section data-markdown>
![coffee](./assets/coffee.png)
</section>
<section>
<section data-markdown>
<script type='text/template'>
<div class='bitly'>[bit.ly/2PJgc7G](http://bit.ly/2PJgc7G)</div>
</script>
</section>
<section data-markdown>
![swipe](./assets/swipe.png)
</section>
</section>
<section data-markdown>
<script type='text/template'>
### Study case: Range Validator
Validate an input number to be between 1 and 100
![code](./assets/code.png)
</script>
</section>
<section data-markdown>
[![sonar report](./assets/sonar-report.png)](http://localhost:9000/dashboard?id=com.rdelgatte%3Apitest-examples)
</section>
<section data-markdown>
![awesome](./assets/awesome.png)
</section>
<section>
<section data-markdown>
Not really... Let's have a look to our unit tests
</section>
<section data-markdown>
![unit-tests-1](./assets/unit-tests-1.png)
</section>
<section data-markdown>
![what](./assets/what.png)
</section>
</section>
<section data-markdown>
![jacoco icon](./assets/jacoco-icon.png)
![jacoco report](./assets/jacoco-report.png)
</section>
<section data-markdown>
### Line coverage
How much of your code lines are executed while processing unit tests
![line-coverage-test](./assets/line-coverage-test.png)
</section>
<section data-markdown>
### Branch coverage
All program branches or conditional states should be tested at least once
![jacoco report](./assets/jacoco-report.png)
</section>
<section data-markdown>
![assert-results](./assets/assert-results.png)
</section>
<section data-markdown>
### How to test your unit tests?
</section>
<section data-markdown>
<script type='text/template'>
<h3><span class='pitest-pink'>Mutation</span> coverage</h3>
</script>
</section>
<section data-markdown>
<script type='text/template'>
## Concept
<p>‘Faults (or <span class='pitest-pink'>*mutations*</span>) are automatically seeded into your code, then your
tests are processed’</p>
</script>
</section>
<section data-markdown>
<script type='text/template'>
## What is a <span class='pitest-pink'>*mutation*</span>?
<ul>
<li class='fragment fade-up'>Replacement of boolean expression with `true` or `false`</li>
<li class='fragment fade-up'>Replacement of arithmetic operations (`+`, `-`, `*`, `/`)</li>
<li class='fragment fade-up'>Changing boolean relations (`>`, `>=`, `<`, `<=`, `==`)</li>
<li class='fragment fade-up'>Statement deletion</li>
<li class='fragment fade-up'>Statement duplication or insertion</li>
</ul>
</script>
</section>
<section>
<section data-markdown>
<script type='text/template'>
If one of your tests fails the mutation is <span class='pitest-pink'>*KILLED*</span>
</script>
</section>
<section>
<h3><span class='good'>✓ GOOD</span></h3>
</section>
</section>
<section>
<section data-markdown>
<script type='text/template'>
Else the mutation <span class='pitest-pink'>*SURVIVED*</span>
</script>
</section>
<section>
<h3><span class='bad'>× BAD</span></h3>
</section>
</section>
<section data-markdown>
<script type='text/template'>
## Assumption
If none of your tests fail when your code is modified
→ your tests *could be* <span class='pitest-pink'>`irrelevant`</span> or <span
class='pitest-pink'>`incomplete`</span>
</script>
</section>
<section data-markdown>
![Pitest](./assets/logo.png)
</section>
<section data-markdown>
<script type='text/template'>
## Configure Pitest
<ul>
<li class='fragment fade-up'>Maven | Gradle | Ant quick starters</li>
<li class='fragment fade-up'>Adding dependency</li>
<li class='fragment fade-up'>Works with JUnit 5</li>
</ul>
http://pitest.org/quickstart
</script>
</section>
<section data-markdown>
<script type='text/template'>
### Configuration
<ul>
<li class='fragment fade-up'>`targetClasses`</li>
<li class='fragment fade-up'>`threads`</li>
<li class='fragment fade-up'>
[`mutators`](https://github.com/hcoles/pitest/blob/master/pitest/src/main/java/org/pitest/mutationtest/engine/gregor/config/Mutator.java)
</li>
<li class='fragment fade-up'>`avoidCallsTo` (e.g. for logging services)</li>
<li class='fragment fade-up'>`skip`</li>
<li class='fragment fade-up'>...</li>
</ul>
</script>
</section>
<section data-markdown>
<script type='text/template'>
### Pitest running and report
![report](./assets/report.png)
</script>
</section>
<section data-markdown>
<script type='text/template'>
### Mutation 1 - RETURN_VALS
![mutation1](./assets/mutation1.png)
<div class='mutation-result-ok'>Test fail ⇒ Mutant is <b>KILLED</b></div>
</script>
</section>
<section data-markdown>
<script type='text/template'>
### Mutation 2 - NEGATE_CONDITIONALS
![mutation2](./assets/mutation2.png)
<div class='mutation-result-ok'>One test fails ⇒ Mutant is <b>KILLED</b></div>
</script>
</section>
<section data-markdown>
<script type='text/template'>
### Mutation 3 - CONDITIONALS_BOUNDARY
![mutation3](./assets/mutation3.png)
<div class='mutation-result-ko'>All tests pass ⇒ Mutant <b>SURVIVED</b></div>
</script>
</section>
<section data-markdown>
<script type='text/template'>
### Handled mutations
<div class='left'>![mutations](./assets/mutations.png)</div>
<div class='right'>![tests](./assets/tests.png)</div>
</script>
</section>
<section data-markdown>
<script type='text/template'>
### How does it work?
<ul>
<li class='fragment fade-up'>Pitest generates mutants by manipulating the bytecode</li>
<li class='fragment fade-up'>A main process holds the list of all possible mutations</li>
<li class='fragment fade-up'>Pitest creates a number of child processes (or <span
class='pitest-pink'>minions</span>) running tests against each mutant</span></li>
</ul>
</script>
</section>
<section data-markdown>
<script type='text/template'>
### A mutant is identified with
<ul>
<li class='fragment fade-up'>Mutation operator</li>
<li class='fragment fade-up'>Class and method signature</li>
<li class='fragment fade-up'>Index to the bytecode instruction which is mutated</li>
</ul>
![minions](./assets/minions.png)
</script>
</section>
<section data-markdown>
<script type='text/template'>
<h3>
<div class='logo'>![tesseract](./assets/tesseract-logo.png)</div>
Tesseract
</h3>
![tesseract](./assets/tesseract.png)
</script>
</section>
<section data-markdown>
<script type='text/template'>
### Feedbacks
<ul>
<li class='fragment fade-up'>Setup is <span class='pitest-pink'>easy</span> (configuration options)</li>
<li class='fragment fade-up'>Fast feedbacks</li>
<li class='fragment fade-up'>It’s fast: 5'30 vs 8’30” (maven) so <span class='pitest-pink'>+3’00</span> for
<span class='pitest-pink'>1200+ unit tests</span></li>
<li class='fragment fade-up'>You need ‘real’ unit tests so it can keep fast and efficient</li>
</ul>
</script>
</section>
<section data-markdown>
<script type='text/template'>
### Continuous integration
![build](./assets/build.png)
</script>
</section>
<section data-markdown>
<script type='text/template'>
### Sonar plugin
![sonar](./assets/sonar.png)
</script>
</section>
<section data-markdown>
<script type='text/template'>
### Going further
<ul>
<li class='fragment fade-up'>
<span class='pitest-pink'>scmMutationCoverage</span> to focus on updated classes (by default *ADDED* or
*MODIFIED*)
</li>
<li class='fragment fade-up'>Setup <span class='pitest-pink'>mutationThreshold</span> or/and <span
class='pitest-pink'>coverageThreshold</span></li>
<li class='fragment fade-up'>Configure new <span class='pitest-pink'>mutators</span></li>
</ul>
</script>
</section>
<section data-markdown>
<script type='text/template'>
### What did we just learn?
<ul>
<li class='fragment fade-up'>Code quality is not just about basic coverage results</li>
<li class='fragment fade-up'>Mutation coverage highlights <span
class='pitest-pink'>unit tests relevance</span>
</li>
<li class='fragment fade-up'>It helps building <span class='pitest-pink'>better unit tests</span></li>
<li class='fragment fade-up'>Pitest is really easy to setup in a java project</li>
</ul>
</script>
</section>
<section data-markdown>
## Going TDD...
Slides: [bit.ly/2OLZKqR](https://bit.ly/2OLZKqR)
Code: [github.com/rdelgatte/pitest-examples](https://github.com/rdelgatte/pitest-examples)
</section>
</div>
</div>
<script src='lib/js/head.min.js'></script>
<script src='js/reveal.js'></script>
<script>
Reveal.initialize({
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
// Zoom in and out with Alt+click
{ src: 'plugin/zoom-js/zoom.js', async: true },
]
});
Reveal.configure({ slideNumber: 'c/t' });
</script>
</body>
</html>