Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mutation testing with Infection

Mutation testing with Infection

With the rise of cyber attacks and an increasing competitive market, it’s even more important to ensure that your application delivers exactly what you had envisioned and you can make changes continuously. By providing mutation testing in your set of tests, you at least have a good indicator where to focus your attention and ensure a successful deployment every time.

In this session we’re going to look at Infection, the Mutation Testing Framework for PHP and show with an example application how these mutations can have a negative impact on your application and how you can use Infection to mitigate these risks and improve the quality of your tests and your application source code.

DragonBe

June 07, 2019
Tweet

More Decks by DragonBe

Other Decks in Programming

Transcript

  1. MICHELANGELO VAN DAM I'm a senior #php architect, co-founder and

    #ceo of @in2itvof, #community leader at @phpbenelux, coach at @CoderDojoBelgium, #MVP, #digitalnomad, likes #coffee. Infec&on: PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)
  2. Small, impactful changes • Function Signature (public, protected visibility) •

    Unwrapping functions and arrays • Binary Arithmetic • Rounding • Boolean substitution • Conditional boundaries • Equal or identical checks • Negated conditionals • Increments • Return values • Removal mutators • Loops • Sorting • Literal numbers • Exceptions • Type casting • Regex • Extensions Infec&on: PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)
  3. An example of a mutation <?php if (array_key_exists('id', $data)) {

    $this->id = (string) $data['id']; } $this->rsvp = 0; if (array_key_exists('yes_rsvp_count', $data)) { $this->rsvp = $data['yes_rsvp_count']; } Infec&on: PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)
  4. An example of a mutation <?php if (array_key_exists('id', $data)) {

    $this->id = (string) $data['id']; } $this->rsvp = 1; if (array_key_exists('yes_rsvp_count', $data)) { $this->rsvp = $data['yes_rsvp_count']; } Infec&on: PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)
  5. An example of a mutation <?php if (array_key_exists('id', $data)) {

    $this->id = (string) $data['id']; } $this->rsvp = 1; if (array_key_exists('yes_rsvp_count', $data)) { $this->rsvp = $data['yes_rsvp_count']; } Infec&on: PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)
  6. Conclusion • Write tests! • Cover mutations • Repeat Infec&on:

    PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)
  7. Improving quality one test at a &me www.in2it.be Infec&on: PHP

    Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)