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.

8fc45f4725efe8e8bc8d6c1f92224b65?s=128

Michelangelo

June 07, 2019
Tweet

Transcript

  1. Infec&on: PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)

  2. 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)
  3. Infec&on: PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)

  4. Infec&on: PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)

  5. 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)
  6. 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)
  7. 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)
  8. 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)
  9. Infec&on: PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)

  10. Infec&on: PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)

  11. Infec&on: PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)

  12. Live Demo Infec&on: PHP Muta&on Tes&ng Framework by Michelangelo van

    Dam (@DragonBe)
  13. Conclusion • Write tests! • Cover mutations • Repeat Infec&on:

    PHP Muta&on Tes&ng Framework by Michelangelo van Dam (@DragonBe)
  14. Get started today! composer require --dev infection/infection ./vendor/bin/infection Infec&on: PHP

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

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