AR
unread,Dec 10, 2009, 4:18:20 PM12/10/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Watir General
Basic application:
I currently have a function in almost every script that is screaming
to be stripped out and put into a global helper.rb file. At the end
of a series of tests, it sends me an email and parses the errors I've
collected stored in the array $errors. This works well, except that
some tests may store 4 items per block in the array, while others may
only store 2 or 3.
I know that I've seen other functions defined where the author was
able to use something like:
def my_function(condition1, condition2, ...)
and therefore collect as many variable as were supplied, no matter
what the limit, but I'm not sure what that is called so Google isn't
helping.
I know this is probably something mundane and simple that I am
overlooking, but I've spent enough time wondering that it is time to
ask.
As for code, I'm currently using the stream method to send me an error
digest. I've marked the line that needs to change on a test by test
basis -- all of the other items I can easily parametrize once I tackle
this problem.
CATCHING THE ERROR
begin
assert_match(expected, actual)
log_success("Expected matches actual") #custom function
rescue
log_failure("Expected does not match actual) #custom function
$errors << [expected, actual]
end #begin
THE EMAIL
def email_errors
int = 0
Net::SMTP.start("##.##.##.##") do |smtp|
smtp.open_message_stream('Automated_Test@#####.com',
'####@#####.com') do |stream|
stream.puts "Subject: ########## Errors"
stream.puts "The following whatevers failed to do the thing
you told them to:"
$errors.each do |exp, act| # ** this is the section that
needs to change on a test by test basis **
int = int + 1
stream.puts ""
stream.puts "#{int}\tCondition:#{exp}"
stream.puts "\tExpected Condition:#{act}"
stream.puts ""
end #$errors
end #smtp
smtp.finish #close the smtp connection
end #Net
end #email_errors