Sha256: 30b0ca23addbf53637e36cfca96379b70a8dc03eb320bc90c61ad533cb9b49cc

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

fault_injection.rb

** FAQ

  * What is it?

    - A 'fault injection' tool for ruby.

  * What is a 'fault injection'? What is it used for?

    - Fault injection is one of testing techniques.
      It makes easier to test your application's error handling behavior or
      to improve the coverage of your tests.
      See http://en.wikipedia.org/wiki/Fault_injection for more details.

  * Can I use it in my application code?

    - No. It is for your testing code.

  * Can I use it everywhere in my test code?

    - You should not. It is for some limited situation that rarely
      happen or difficult to set up (ex. IOError).
      If you can make 'evil situation' easily, that's better ;)

** Installing

$ sudo gem install faultinjection

** Sample codes

  # sample.rb
  class Foo
    def foo
      puts "I love injection"
    end

    def bar
      10 / 2  # this is line 7
    end
  end
  __END__

  # test.rb
  require 'fault_injection'
  include FaultInjection

  inject "Foo#foo > Kernel#puts", IOError, "IO error"

  f = Foo.new
  f.foo #=> IOError

  inject "sample.rb:7",ZeroDivisionError

  f.bar #=> ZeroDivisionError
  __END__


** License

This code is free to use under the terms of the MIT license. 

** Contact

The SVN repository is available at http://faultinjection.rubyforge.org/svn/

Comments are welcome. Feel free to Send an email to keisukefukuda@gmail.com
(Please include 'ruby' or 'fault_injection' in the title).


Thank you for using fault_injection.rb

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faultinjection-0.0.1 README.txt