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

Mutation Testing - Backend Meetup @ STRV

Mutation Testing - Backend Meetup @ STRV

Ruan Martinelli

April 09, 2020
Tweet

More Decks by Ruan Martinelli

Other Decks in Programming

Transcript

  1. MUTATION TESTING
    Ruan Martinelli, Backend Developer at STRV

    View full-size slide

  2. 2
    https://en.wikipedia.org/wiki/Category:Software_testing

    View full-size slide

  3. 1. REPLACE "AND" WITH "OR"
    3

    View full-size slide

  4. 2. REPLACE "+" WITH "-"
    4

    View full-size slide

  5. 3. CODE COVERAGE
    5

    View full-size slide

  6. 3. CODE COVERAGE
    6

    View full-size slide

  7. 3. CODE COVERAGE
    7

    View full-size slide

  8. “What if I told you there is a codebase
    that is not yours and it passes all your
    tests?
    What if told you there are 200?”
    8

    View full-size slide

  9. Mutations are small "faults" or "bugs" inserted into your code.
    When a mutation is applied to the code, a mutant is created.
    Mutation testing:
    1. Change your code in small ways
    2. Run the test suite once for each changed version
    3. Analyze results
    - If one or more test breaks, it’s said that the mutant was killed
    - If all tests passes, it’s said that the mutant survived
    MUTATIONS, MUTANTS & MUTATION TESTING
    9

    View full-size slide

  10. 4. LIST OF COMMON MUTATIONS
    10

    View full-size slide

  11. List of Mutation Testing tools:
    ● Java - PIT
    ● Ruby - Mutant
    ● PHP - Infection
    ● C# - VisualMutator & Stryker.NET
    ● Python - MutPy
    ● JavaScript - Stryker
    TOOLING
    11

    View full-size slide

  12. KOA.JS
    13
    ● Koa.js has 345 tests which take ~3s to run
    ● 4 files were mutated, 793 mutants were created
    ● Total execution time was 12m28s (8 cores)

    View full-size slide

  13. Mutation testing is resource and time-consuming
    ● Run tests in the cloud periodically
    ● Parallelism and distributed computing
    ● Diff-based approach
    ● AI & Machine learning
    ● Run only on critical parts of your system
    GOING FURTHER
    21

    View full-size slide

  14. THANK YOU!
    Ruan Martinelli / [email protected] / @ruanmartinelli
    22

    View full-size slide