Search the web
Sign In
New User? Sign Up
TestFirstUserInterfaces
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Re: [agile-testing] Re: Using examples to drive development   Message List  
Reply | Forward Message #1041 of 1051 |
Lisa Crispin wrote:

> We definitely want to do these investigative efforts. But I still feel
> examples are a good way to start. What have other folks found on their
> projects?

I have to confess a low rate of adoption for my assert_xpath project, to
unit-test raw HTML. As a computer scientist and a DSL-zealot, I _like_ writing
inhumanly elaborate queries, like '//fieldset[ following-sibling::input[ @name =
"etc" ] ]'.

Someone on the net recently challenged a forum to write an assertion like that,
but in this format, and I did it:

assert_xhtml do
form @action do
fieldset do
label 'first name'
input :name => 'etc'
end
end
end

Easier to read, huh? The HTML element names are all raw Ruby; they call
method_missing(), to convert into XPath expressions like that, on the fly.

That forum was the RSpec mailing list, and this leads to an interesting
observation. RSpec, and Behavior Driven Development, were _supposed_ to be about
the customer tests. Yet these days the general Ruby on Rails community now
considers TDD (and the test/unit library) to be OLD SCHOOL!

All the new, cool projects use RSpec. It appears that programmers like to
specify their designs by example, too.

Here's that assertion's RSpec version:

@response.body.should be_html_with{
form @action do
fieldset do
label 'first name'
input :name => 'etc'
end
end
}

Like all good examples, those assertions skip over irrelevant details, such as
intervening <table>, <div>, <li> tags, or whatever.

(Those of you with Ruby can try those by grabbing the assert2 gem; then calling
require 'assert2/xhtml'.)

--
Phlip
http://www.zeroplayer.com/



Wed Mar 18, 2009 2:34 am

phlipcpp
Offline Offline
Send Email Send Email

Forward
Message #1041 of 1051 |
Expand Messages Author Sort by Date

... I have to confess a low rate of adoption for my assert_xpath project, to unit-test raw HTML. As a computer scientist and a DSL-zealot, I _like_ writing ...
Phlip
phlipcpp
Offline Send Email
Mar 18, 2009
2:34 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help