Giter VIP home page Giter VIP logo

devel-mutator's Introduction

NAME

Devel::Mutator - Mutation testing for Perl

SYNOPSIS

mutator mutate lib/MyModule.pm
mutator test

DESCRIPTION

Devel::Mutator is a mutation testing toolkit for Perl. Mutation testing is changing the working program in different ways and checking that the test suite fails and thus detecting the bad testing.

How it works

First we generate mutated code. For example every occurance of = is replaced by !=. All the mutants are collected in the mutants/ directory. Then we run the tests replacing original code by the mutant. If the test suite does not fail when the code is changed it is reported with a diff output, which helps to see the problem.

(10/18) ./mutants/7021082cc1c0afbe9322f60a9b5e5d5f/lib/Input/Validator/Field.pm ... not ok
--- ./mutants/7021082cc1c0afbe9322f60a9b5e5d5f/lib/Input/Validator/Field.pm Sat Nov  1 11:27:00 2014
+++ lib/Input/Validator/Field.pm.bak    Sun May 18 21:50:14 2014
@@ -14,7 +14,7 @@
     my $self = shift;

     $self->{constraints} ||= [];
-    $self->{messages}    //= {};
+    $self->{messages}    ||= {};

     $self->{trim} = 1 unless defined $self->{trim};

Here we can see that the test suite does not check the need for //.

Warning

The original code is replaced by the mutants, so make sure it is under a VCS if something bad happens. This is the easiest and the 100% working way. Maybe this will be changed in the future when a better way is found.

Mutation testing drawbacks

There are several drawbacks.

The equivalent program

The equivalent program can be produced thus failing the test. There is no solution to that for now.

Infinite loops

Infinite loops can be created easily. The solution is to run the test suite limited in time through a timeout option, which is 10s by default. After 10s of running, the test suite is killed and n/a timeout is reported.

METHODS

CREDITS

Alexandr Ciornii (chorny)

Tim Teasdale (hooverbag)

Patricio Valle (pvallev)

AUTHOR

Viacheslav Tykhanovskyi, [email protected]

COPYRIGHT AND LICENSE

Copyright (C) 2015, Viacheslav Tykhanovskyi

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

devel-mutator's People

Contributors

chorny avatar hooverbag avatar patriciovalle avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.