Sha256: 84e815f1722d3975b2a8c67e22fdaaa30d9fd7d33cc693d3f4053446d9e5bd2c

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

h1. fault_injection.rb

h2. Overview

h3. What is it?

A 'fault injection' tool for ruby.

h3. 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 <a herf="http://en.wikipedia.org/wiki/Fault_injection">
http://en.wikipedia.org/wiki/Fault_injection
</a> for more details.

h3. Can I use it in my application code?

No. It is for your testing code.

h3. 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 ;)

h2. Installing

<pre syntax="ruby">sudo gem install faultinjection</pre>

h2. Sample codes

<pre syntax="ruby">

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

  def bar
    10 / 2  # this is line 7
  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

</pre>

h2. License

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

h2. Contact

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

Comments are welcome. Feel free to Send an email to keisukefukuda.spam@gmail.com

(Please remove ".spam" from the address for anti-spam, and include 'ruby' or 'fault_injection' in the title)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faultinjection-0.0.1 website/index.txt