[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Continue code run after assert exception

aidy

9/22/2006 10:30:00 AM

I am iterating through a collection and using Test::Unit assertations
on each object

begin
search.each {|@x|
assert($ie.contains_text(@x)) }
rescue => e
puts "#{@x} does not exist in HTML"
end

However, the problem is that if the first assertation is false, an
exception is thrown and my loop terminates. I would like to continue
the loop after an exception is thrown. I have tried 'retry', but I find
myself in an infinite loop.

Thanks

aidy

12 Answers

dblack

9/22/2006 10:57:00 AM

0

Pit Capitain

9/22/2006 1:15:00 PM

0

aidy schrieb:
> I am iterating through a collection and using Test::Unit assertations
> on each object
>
> begin
> search.each {|@x|
> assert($ie.contains_text(@x)) }
> rescue => e
> puts "#{@x} does not exist in HTML"
> end
>
> However, the problem is that if the first assertation is false, an
> exception is thrown and my loop terminates. I would like to continue
> the loop after an exception is thrown. I have tried 'retry', but I find
> myself in an infinite loop.

Aidy, are you using this code in a unit test, or are you using the
assertions as part of your normal code? If this is normal code, see
David's answer how to catch the error inside the loop.

If this is part of a unit test, and you want to report every false
element, take a look at the code in

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-t...

With this module, your test could look like:

class MyTestCase < Test::Unit::TestCase

include ErrorCollector

def test_search_screen
...
collecting_errors do
search.each do |@x|
assert($ie.contains_text(@x), "#{@x} does not exist in HTML")
end
end
end

end

Regards,
Pit

Michael Swift

7/10/2013 11:13:00 AM

0

In article <b44ls4Fk44gU1@mid.individual.net>, tim.....
<tims_new_home@yahoo.co.uk> writes
>And we should be keeping the rules enabling us to enforce fines for traffic
>offences/tolls against foreign registered drivers.

What's the point, they are unenforceable, now if they were on the spot
fines, but if we didn't treat British drivers in the same way the EU
would enter super whinge mode.

Mike

--
Michael Swift We do not regard Englishmen as foreigners.
Kirkheaton We look on them only as rather mad Norwegians.
Yorkshire Halvard Lange

tim \(not at home\)

7/10/2013 12:37:00 PM

0


"Michael Swift" <mike.swift@yeton.co.uk> wrote in message
news:5qNk2JA2GU3RFwDD@ntlworld.com...
> In article <b44ls4Fk44gU1@mid.individual.net>, tim.....
> <tims_new_home@yahoo.co.uk> writes
>>And we should be keeping the rules enabling us to enforce fines for
>>traffic
>>offences/tolls against foreign registered drivers.
>
> What's the point, they are unenforceable,

no they are not (they may be un-collectable, that's not the same thing)

> now if they were on the spot fines,

not the "British" way is it

tim



Michael Swift

7/10/2013 12:55:00 PM

0

In article <b452r5Fms13U1@mid.individual.net>, tim.....
<tims_new_home@yahoo.co.uk> writes
>>>And we should be keeping the rules enabling us to enforce fines for
>>>traffic
>>>offences/tolls against foreign registered drivers.
>>
>> What's the point, they are unenforceable,
>
>no they are not (they may be un-collectable, that's not the same thing)

Near as dammit, I suppose you could enforce them if you spent a fortune
on foreign lawyers.

Mike

--
Michael Swift We do not regard Englishmen as foreigners.
Kirkheaton We look on them only as rather mad Norwegians.
Yorkshire Halvard Lange

Fredxx

7/10/2013 2:07:00 PM

0

On 10/07/2013 13:54, Michael Swift wrote:
> In article <b452r5Fms13U1@mid.individual.net>, tim.....
> <tims_new_home@yahoo.co.uk> writes
>>>> And we should be keeping the rules enabling us to enforce
>>>> fines for traffic offences/tolls against foreign registered
>>>> drivers.
>>>
>>> What's the point, they are unenforceable,
>>
>> no they are not (they may be un-collectable, that's not the same
>> thing)
>
> Near as dammit, I suppose you could enforce them if you spent a
> fortune on foreign lawyers.
>

They are enforceable for the next time a registered keeper or the
nominated enters the UK. It just requires patience and a holding cell
at each port or airport.

tim \(not at home\)

7/10/2013 7:32:00 PM

0


"Michael Swift" <mike.swift@yeton.co.uk> wrote in message
news:e7z9SWAPmV3RFwXm@ntlworld.com...
> In article <b452r5Fms13U1@mid.individual.net>, tim.....
> <tims_new_home@yahoo.co.uk> writes
>>>>And we should be keeping the rules enabling us to enforce fines for
>>>>traffic
>>>>offences/tolls against foreign registered drivers.
>>>
>>> What's the point, they are unenforceable,
>>
>>no they are not (they may be un-collectable, that's not the same thing)
>
> Near as dammit, I suppose you could enforce them if you spent a fortune on
> foreign lawyers.

but that's the point of having an agreement on cross border collection, to
save on such costs.





Michael Swift

7/10/2013 10:40:00 PM

0

In article <b45r5bFs4qdU1@mid.individual.net>, tim.....
<tims_new_home@yahoo.co.uk> writes
>>>>>And we should be keeping the rules enabling us to enforce fines for
>>>>>traffic
>>>>>offences/tolls against foreign registered drivers.
>>>>
>>>> What's the point, they are unenforceable,
>>>
>>>no they are not (they may be un-collectable, that's not the same thing)
>>
>> Near as dammit, I suppose you could enforce them if you spent a fortune on
>> foreign lawyers.
>
>but that's the point of having an agreement on cross border collection, to
>save on such costs.

Does that actually work, all I hear is the whinging about unpaid fines
run up by foreign drivers.

Mike

--
Michael Swift We do not regard Englishmen as foreigners.
Kirkheaton We look on them only as rather mad Norwegians.
Yorkshire Halvard Lange

tim \(not at home\)

7/11/2013 2:34:00 PM

0


"Michael Swift" <mike.swift@yeton.co.uk> wrote in message
news:1wOHAJA7Ke3RFwjq@ntlworld.com...
> In article <b45r5bFs4qdU1@mid.individual.net>, tim.....
> <tims_new_home@yahoo.co.uk> writes
>>>>>>And we should be keeping the rules enabling us to enforce fines for
>>>>>>traffic
>>>>>>offences/tolls against foreign registered drivers.
>>>>>
>>>>> What's the point, they are unenforceable,
>>>>
>>>>no they are not (they may be un-collectable, that's not the same thing)
>>>
>>> Near as dammit, I suppose you could enforce them if you spent a fortune
>>> on
>>> foreign lawyers.
>>
>>but that's the point of having an agreement on cross border collection, to
>>save on such costs.
>
> Does that actually work, all I hear is the whinging about unpaid fines run
> up by foreign drivers.

It doesn't work because it doesn't yet exist.

The point of discussion is whether we should opt into the pan-EU system that
is proposed (the advantage of not opting in is, presumably, that foreign
counties can't retrospectively collect fines/tolls racked up by UK residents
when they are on holiday - but I don't think that we should advantage these
people at the expense of advantaging foreigner truck drivers in the UK,
especially as many EU counties have on-the spot fines that can't be
avoided).

tim


Michael Swift

7/11/2013 3:11:00 PM

0

In article <b47u2nFb1euU1@mid.individual.net>, tim.....
<tims_new_home@yahoo.co.uk> writes
>>>>>>>And we should be keeping the rules enabling us to enforce fines for
>>>>>>>traffic
>>>>>>>offences/tolls against foreign registered drivers.
>>>>>>
>>>>>> What's the point, they are unenforceable,
>>>>>
>>>>>no they are not (they may be un-collectable, that's not the same thing)
>>>>
>>>> Near as dammit, I suppose you could enforce them if you spent a fortune
>>>> on
>>>> foreign lawyers.
>>>
>>>but that's the point of having an agreement on cross border collection, to
>>>save on such costs.
>>
>> Does that actually work, all I hear is the whinging about unpaid fines run
>> up by foreign drivers.
>
>It doesn't work because it doesn't yet exist.
>
>The point of discussion is whether we should opt into the pan-EU system
>that is proposed (the advantage of not opting in is, presumably, that foreign
>counties can't retrospectively collect fines/tolls racked up by UK residents
>when they are on holiday - but I don't think that we should advantage these
>people at the expense of advantaging foreigner truck drivers in the UK,
>especially as many EU counties have on-the spot fines that can't be
>avoided).

Sorry, it's the bit at the top you posted, 'And we should be keeping the
rules enabling us to enforce fines for traffic offences/tolls against
foreign registered drivers.', that confused me.

Reading that suggests to me that it's are already in place and not 'work
in progress'.

As long as everyone obeys the rules and doesn't do a France then I'm all
for it.

Mike

--
Michael Swift We do not regard Englishmen as foreigners.
Kirkheaton We look on them only as rather mad Norwegians.
Yorkshire Halvard Lange