Hugh,
I am a nubie and I understand what you are saying that less is more...
However, Readability of code is important for me... Especially when
explaining the code to others in the office and having others in the
office follow the code six months from now...
While you are technically correct, less is more... In my case,
readability is a high priority for me and less is... Well, less. My goal
is to make it compact but readable by others...
An example of the scripts I write is as follows... I would invite
suggestions on making it tighter but still retain the readability so
that 6 months from now when someone else in the office has to update
this script to make it work with changes to the webpage... It will be
easy to update and understand...
def test_new_user
#variables
test_site = 'http://a_location'
test_add_url = 'http://another_location'
test_FN_field = 'xxxxx'
test_LN_field = 'xxxxx'
test_FN_value = 'xxxxx'
test_LN_value = 'xxxxx'
test_ID_field = 'xxxxx'
test_ID_value = 'xxxxx'
test_EM_field = 'xxxxx'
test_EM_value = 'xxxxx'
test_P1_field = 'xxxxx'
test_P1_value = 'xxxxx'
test_P2_field = 'xxxxx'
test_P2_value = 'xxxxx'
test_SN_field = 'xxxxx'
test_SN_value = 'xxxxx'
test_SE_field = 'xxxxx'
test_SE_value = 'xxxxx'
test_CF_field = 'xxxxx'
test_CF_value = 'xxxxx'
test_select_index = 'xxxxx'
test_look_text = "This Student ID is already in use. Please select
another Student ID."
#go to the test page
$ie.goto(test_site)
$ie.goto(test_add_url)
# add the page details
$ie.text_field(:name, test_FN_field).set(test_FN_value)
$ie.text_field(:name, test_LN_field).set(test_LN_value)
$ie.text_field(:name, test_ID_field).set(test_ID_value)
$ie.text_field(:name, test_EM_field).set(test_EM_value)
$ie.text_field(:name, test_P1_field).set(test_P1_value)
$ie.text_field(:name, test_P2_field).set(test_P2_value)
$ie.text_field(:name, test_SN_field).set(test_SN_value)
$ie.text_field(:name, test_SE_field).set(test_SE_value)
$ie.text_field(:name, test_CF_field).set(test_CF_value)
$ie.select_list( :index , 1).select(test_select_index)
#submit page
$ie.button(:name, "submit").click
#check for expected text
begin
assert($ie.contains_text(test_look_text) )
$logger.log("###NEW USER TEST PASSED####' ")
$logger.log_results("test_new_user", test_look_text,
test_look_text, "TEST PASSED.")
rescue => e
$logger.log("###NEW USER TEST FAILED####" + e.message + "\n" +
e.backtrace.join("\n"))
$logger.log_results("test_new_user", test_look_text,
test_look_text, "TEST FAILED.")
end
#return to the admin page
$ie.link(:text, "administration").click
end # end test_new_user
Regards,
Thom
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Hugh Sasse
Sent: Tuesday, February 07, 2006 4:01 PM
To: [email protected]
Subject: Re: [Wtr-general] Assertions help
On Tue, 7 Feb 2006, Thomas Healy wrote:
> Hugh,
>
> I will stick to mine... I am a nubie and I understood very little of
> what you just wrote... I am sure as I go along and get more skilled...
> It will start to make sense... But for the new guy (me)... Readability
> & understandability is important...
Yes, but writing less code means less chance to write bugs.
Basically, you want tests to pass unless they cannot. The asserts
determine whether a test is on track to pass. If an assert fails,
Test::Unit does the begin...rescue...end magic for you, and bails out,
and so that one test fails. It then allows the other tests to be run,
in case those bits of code still work.
Does that help? Else, tell me what baffles, and I'll try to explain
differently.
>
> Thanks,
>
> Thom
>
Hugh
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general