continue execution when TEST::UNIT assertion fails

Discussion in 'Ruby' started by aidy, Apr 16, 2007.

  1. aidy

    aidy Guest

    Hi,

    Is is possible not to halt the execution of a ruby script when an
    TEST::UNIT assertion fails?

    cheers

    aidy
     
    aidy, Apr 16, 2007
    #1
    1. Advertising

  2. aidy

    Tim Pease Guest

    On 4/16/07, aidy <> wrote:
    > Hi,
    >
    > Is is possible not to halt the execution of a ruby script when an
    > TEST::UNIT assertion fails?
    >


    Yes, you can ...

    begin
    assert false
    rescue Test::Unit::AssertionFailedError => e
    self.send:)add_failure, e.message, e.backtrace)
    end


    Or if you would like a little method ...

    def continue_test
    begin
    yield
    rescue Test::Unit::AssertionFailedError => e
    self.send:)add_failure, e.message, e.backtrace)
    end
    end

    continue_test( assert false )


    Blessings,
    TwP
     
    Tim Pease, Apr 16, 2007
    #2
    1. Advertising

  3. aidy

    Tim Pease Guest

    On 4/16/07, Tim Pease <> wrote:
    > On 4/16/07, aidy <> wrote:
    > > Hi,
    > >
    > > Is is possible not to halt the execution of a ruby script when an
    > > TEST::UNIT assertion fails?
    > >

    >
    > Yes, you can ...
    >
    > begin
    > assert false
    > rescue Test::Unit::AssertionFailedError => e
    > self.send:)add_failure, e.message, e.backtrace)
    > end
    >
    >
    > Or if you would like a little method ...
    >
    > def continue_test
    > begin
    > yield
    > rescue Test::Unit::AssertionFailedError => e
    > self.send:)add_failure, e.message, e.backtrace)
    > end
    > end
    >
    > continue_test( assert false )
    >


    Sorry, that should be a block

    continue_test {assert false}

    TwP
     
    Tim Pease, Apr 16, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    178
    Bret Pettichord
    Oct 7, 2005
  2. Curt Sampson
    Replies:
    3
    Views:
    127
    Phlip
    Aug 11, 2007
  3. Replies:
    1
    Views:
    114
  4. John Smith

    Test::unit assertion pass scenario

    John Smith, Dec 30, 2009, in forum: Ruby
    Replies:
    12
    Views:
    286
    Phillip Gawlowski
    Dec 31, 2009
  5. timr
    Replies:
    2
    Views:
    176
Loading...

Share This Page