Slide 1

Slide 1 text

Mutation testing 101 Form3 Friday Sharing 25th June 2019

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

https://i.ytimg.com/vi/QUyPALAJFpU/maxresdefault.jpg

Slide 4

Slide 4 text

“Internal” vs “External” quality The system / component / whatever behaves as expected... ● https://martinfowler.com/articles/microservice-testing/ ● Specification by example / ATDD / BDD ● Example mapping ● Functional testing ● Contract testing ● Exploration testing ● Performance testing ● Penetration testing ● etc...

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

Metrics, metrics everywhere... ● Cyclomatic complexity ● Duplications ● Code smells ● Maintainability ● Technical debt ● Test duration ● Test coverage: are we covering all the “possible” behaviours of the system? https://sonarcloud.io/dashboard?id=com.islomar.payments%3Apayments-api

Slide 7

Slide 7 text

“Tell me how you measure me, and I will tell you how I will behave” Eliyahu M. Goldratt “You get what you measure”

Slide 8

Slide 8 text

assertTrue(true);

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

https://www.wallpaperup.com/865120/X-MEN_superhero_marvel_action_adventure_sci-fi_warrior_fantasy_fighting_hero_xmen_1xmena_com ics_poster.html Mutation testing to the rescue!!

Slide 11

Slide 11 text

https://www.guru99.com/mutation-testing.html

Slide 12

Slide 12 text

Simple examples of mutators ● Conditional boundaries ● Increments ● Invert negatives ● Math ● Negation ● Return values ● Void method calls ● Constructor calls ● Empty returns ● False/True returns ● Remove conditionals ● etc...

Slide 13

Slide 13 text

Conditional boundaries mutators http://pitest.org/quickstart/mutators/

Slide 14

Slide 14 text

Negate conditional mutators http://pitest.org/quickstart/mutators/

Slide 15

Slide 15 text

Math mutators http://pitest.org/quickstart/mutators/

Slide 16

Slide 16 text

Return values mutator

Slide 17

Slide 17 text

Void method call mutator http://pitest.org/quickstart/mutators/

Slide 18

Slide 18 text

Demo time

Slide 19

Slide 19 text

Demo time (in Java… oopsss!!) https://github.com/islomar/payments-api https://github.com/islomar/parrotter https://github.com/sandromancuso/Gilded-Rose-Kata (100% test coverage)

Slide 20

Slide 20 text

Final considerations ● High test coverage means almost NOTHING. Low test coverage is a smell... ● Mutation testing: only for isolated tests (aka “unit tests”): tests which are fast (FIRST) ● Start with the basic mutators ● Depending on the complexity and size of the code, it can be very time/resource consuming, watch out!! (combinatorial explosion) ○ In Pitest you can activate “incremental analysis” (experimental feature)

Slide 21

Slide 21 text

Resources (I) GOTO 2015: Mutation testing in Python https://www.youtube.com/watch?v=jwB3Nn4hR1o Mutation testing in Python with Cosmic Ray https://vimeo.com/171319754 Vicenç García en SCBCN (in Spanish) https://www.youtube.com/watch?v=LWL71b2fc64 Madrid JUG (in Spanish) https://www.youtube.com/watch?v=hk_urzWGqrE

Slide 22

Slide 22 text

Resources (II) https://www.slideshare.net/RafaelVindelAmor/who-watches-the-watchmen-mutation-te sting-75767706 https://www.st.cs.uni-saarland.de/edu/testingdebugging10/slides/10-MutationTesting.pdf https://hackernoon.com/mutmut-a-python-mutation-testing-system-9b9639356c78

Slide 23

Slide 23 text

https://looneytunes.fandom.com/wiki/That%27s_all_Folks

Slide 24

Slide 24 text

No content