Sha256: 8b04fbf314e010fb9a62f9e300c2e0a49701f5cc2c96c77e257b77f46330dcd2

Contents?: true

Size: 1.24 KB

Versions: 12

Compression:

Stored size: 1.24 KB

Contents

# Raising any exceptions will quit processing the test BY designating it as FAIL.
# *  OatsTestError:   Use for any generic test execution exception
# *  OatsVerifyError: Use for to quit processing during output verification. See
#    example/verifyException
# DO NOT USE 'exit'.
# * Use Oats.error to register failures during execution.
# * See example/basic for how to use Oats.error

begin # Exceptions raised within this block will
      # be caught by the following rescue clauses
  Oats.info "If something unexpected happens here, like division by zero,"
  Oats.info "the second catch-all rescue will get it."
  1/0

rescue Errno::ENOENT # Handled here, no problem
  Oats.warn "Rescued exception's message: " + $!
  Oats.warn "This was expected. Here is the full stack trace:"
  Oats.warn $! # Print stack strace only if warranted

rescue # All other types of exceptions
  Oats.warn "Got it: " + $!
  Oats.warn "If you don't know how to handle it fully, push it up the chain."
  Oats.info "OATS will catch it automatically and mark the test as failed."
  raise $!

ensure # If you need something that always gets executed, even after exceptions
  Oats.info "Do some test cleanup right here."
end

Oats.info "Due to raised exception above, this will not get executed."

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
oats-0.1.4 oats_tests/examples/core/unexpectedException.rb
oats-0.1.1 oats_tests/examples/core/unexpectedException.rb
oats-0.1.0 oats_tests/examples/core/unexpectedException.rb
oats-0.0.9 oats_tests/examples/core/unexpectedException.rb
oats-0.0.8 oats_tests/examples/core/unexpectedException.rb
oats-0.0.7 oats_tests/examples/core/unexpectedException.rb
oats-0.0.6 oats_tests/examples/core/unexpectedException.rb
oats-0.0.5 oats_tests/examples/core/unexpectedException.rb
oats-0.0.4 oats_tests/examples/core/unexpectedException.rb
oats-0.0.3 oats_tests/examples/core/unexpectedException.rb
oats-0.0.2 oats_tests/examples/core/unexpectedException.rb
oats-0.0.1 oats_tests/examples/core/unexpectedException.rb