Phlip | 8 Mar 2007 18:46
Picon
Gravatar

[TFUI] test-driven Ajax

Adam Sroka wrote:

> ...Given that most web apps
> today are highly dependent on the Ajax stack I would not trust these
> frameworks unless they have *greatly* improved since the last time I
> looked at them.

If I can avoid my usual plagues and disasters for just a couple more
weeks now, I will _finally_ be publishing a chapter of /TFUI/.
(Woo-hoo! and _incredibly_ sorry about the wait, everyone!)

The chapter shows how to use Rails and Ajax to write a test runner, in
the style of Watir or Selenium. It uses Ajax to edit and maintain test
cases in a web page, and tests target pages in an IFrame.

The chapter shows how to build the core of this tool from Rails, its
existing test rigs, and some new test rigs I assemble on the fly. It
invents:

assert_xpath
assert_js
assert_ajax

Anyone proficient with Rails can sample the test runner itself here:

http://phlip.svnrepository.com/svn/yar_wiki/README

It currently beats on a couple of my Rails projects. If you install it
but don't build a controller for it, you get assert_xpath and
assert_js. (Only the wiki can do assert_ajax!)

Here's an extreme example of assert_xpath:

assert_xml x.target!

assert_xpath '/ul/li/table/tr/td/strong[ . = "test_hammy_squirrel" ]' do
assert_xpath '../../../../ul/li/table/tr/td/strong[ . = "script" ]' do
assert_xpath '../../../../div[ . = "# something tests hammy squirrel" ]'
end
end

The first assertion takes a string, parses it as XML, and puts it into
a secret member variable called <at> xdoc. The assert_xpath requires a
valid path, so you can put lots of query details into the path. Then
assert_xpath upgrades <at> xdoc to point to the selected node, and it
calls a block. assert_xpath inside the block then works on the
selected node. In the above example (which could be more ...
exemplary), the nested assert_xpath calls respond by reaching back up
the tree of nodes, and finding distant cousins of the selected nodes.

assert_js lexes intermediate JavaScript source into XML, so
assert_xpath can then query out its important details:

assert_xpath '/form/textarea' do |textarea|
assert_js textarea.attributes['onkeydown'] do
assert_xpath 'Statement[1]' do
assert_xpath '//Identifier[ <at> name = "Callee" and . =
"editor_keydown" ]'
end
end
end

That might be better than "assert_match /onkeydown.*editor_keydown/,
my_javascript". The match could break when irrelevant details change.

assert_ajax works by registering a JavaScript callback to file when an
Ajax command finishes. You can populate the callback with assertions
to check that your Ajax updated your DOM correctly.

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!

__._,_.___
Recent Activity
Visit Your Group
SPONSORED LINKS
Cool Websites

Know a good site?

Share and vote

on Bix.com!

Ads on Yahoo!

Learn more now.

Reach customers

searching for you.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
Phlip | 9 Mar 2007 23:23
Picon
Gravatar

[TFUI] Re: [Rails-spinoffs] Re: Trying to develop a web graphical editor

> Diodeus wrote:
>
> > http://beta.moveable.com/jameslab/ajaxio/
>
> Radical!

Another followup. The last time I did this project (I cheated and used
TkCanvas, instead of our endlessly convoluted Ajax landscape), I used
GraphViz for the geometry manager. That means, after the user declares
nodes and connections, I submit them as text to GraphViz, and it
determines the layout, using an industrial-strength and very
customizable constraint engine. Then it returns a raw geometry, and I
snap everything to its coordinates.

Here's an example using SVG as the intermediate layer:

http://wiki.rubygarden.org/Ruby/page/show/SvgCanvas

If you follow that, the links are kind'a old, so if anything broke
I'll refresh it. But there are better versions of SvgCanvas on my
desktop(s).

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!

__._,_.___
Recent Activity
Visit Your Group
SPONSORED LINKS
Cool Websites

Know a good site?

Share and vote

on Bix.com!

Need traffic?

Drive customers

With search ads

on Yahoo!

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
Phlip | 10 Mar 2007 22:04
Picon
Gravatar

Re: help for learn of XP

Ian Collins wrote:

>>"Ruby on Rails" was invented using most of the XP practices. For example, 
>>it
>>is unique among web development platforms for letting you easily write 
>>unit
>>tests for every aspect of a web application.

> How does it differ form using something like PHPUint and JSUnit?

To answer the OP, those are *Units. Rails is a complete application; an 
example of a project.

The difference with *Units in general is Rails's test framework has 
assertions and systems that match each layer of Rails's web framework. 
Here's a trivial example of submitting a form:

    login_as :ian
    get :index

    submit_form('edit_user') do |form|
      assert_equal '4111111111111118', form['user[cc]'].value
      assert_equal '', form['user[charge]'].value
      form['user[widget]'] = 'widget_3'
    end

    assert_equal 1,  <at> tygr.widgets.count

The first line comes from custom test-side code that logs us into the 
authentication system.

The second line gets the 'index.rhtml' file and processes it as if a web 
browser had sent it. This follows the "Mock the Server" pattern.

index.rhtml has a form that calls the edit_user server action. So the 
submit_form line is an assertion that finds the form, and then simulates 
sending its data

The do-end block can assert the form's variables, and can change them. If 
the form doesn't have a given 'user[field]' input item, by name, the 
assertion will fail. This prevents the degenerate situation where the tests 
send info to the back end that the user interface does not send. The same 
assertion tests the GUI and back-end at the same time.

--

-- 
  Phlip
  http://www.greencheese.us/ZeekLand <-- NOT a blog!!! 

To Post a message, send it to:   extremeprogramming <at> eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-unsubscribe <at> eGroups.com

ad-free courtesy of objectmentor.com 
Phlip | 20 Mar 2007 17:53
Picon
Gravatar

[TFUI] Re: [TDD] Is a bad test better than no test at all?

Ben Rady wrote:

> I'm a project manager/technical lead at a company that builds tools for 2D
> and 3D graphics, and my team is fully test infected. We've had a debate
> going on for some time about what to do about inconsistent tests.

Your tests which run a long way from the tested code are insufficiently fuzzy?

> ...But when we do find them they always suck a lot of time away
> from the poor developer who's just trying to check in a change...

Can you get them to fail within 5 seconds of hitting the One Test
Button, while editing?

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!

__._,_.___
Recent Activity
Visit Your Group
Cool Websites

Know a good site?

Share and vote

on Bix.com!

Need traffic?

Drive customers

With search ads

on Yahoo!

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
Tim Ottinger | 20 Mar 2007 19:22
Picon
Favicon
Gravatar

Re: [TFUI] Re: [TDD] Is a bad test better than no test at all?

If the test runs quickly, returns true results (no tail chasing from false false negatives, no misdirection through false positives), then keep it. It's useful. If it sometimes returns false results or takes a long time, then fuzzy is bad.

Ultimately, I fall back on Michael Feathers' "1) runs quickly, 2) helps to isolate errors". If it is too fuzzy for either of the criteria, it's too fuzzy. Otherwise, not.

----- Original Message ----
From: Phlip <phlip2005 <at> gmail.com>
To: testdrivendevelopment <at> yahoogroups.com
Cc: testfirstuserinterfaces <at> yahoogroups.com
Sent: Tuesday, March 20, 2007 9:53:27 AM
Subject: [TFUI] Re: [TDD] Is a bad test better than no test at all?

Ben Rady wrote:

> I'm a project manager/technical lead at a company that builds tools for 2D

> and 3D graphics, and my team is fully test infected. We've had a debate

> going on for some time about what to do about inconsistent tests.

Your tests which run a long way from the tested code are insufficiently fuzzy?

> ...But when we do find them they always suck a lot of time away

> from the poor developer who's just trying to check in a change...

Can you get them to fail within 5 seconds of hitting the One Test

Button, while editing?

--

Phlip

http://c2.com/ cgi/wiki? ZeekLand <-- NOT a blog!!

<!--

#ygrp-mlmsg {font-size:13px;font-family:arial, helvetica, clean, sans-serif;}
#ygrp-mlmsg table {font-size:inherit;font:100%;}
#ygrp-mlmsg select, input, textarea {font:99% arial, helvetica, clean, sans-serif;}
#ygrp-mlmsg pre, code {font:115% monospace;}
#ygrp-mlmsg * {line-height:1.22em;}
#ygrp-text{
font-family:Georgia;
}
#ygrp-text p{
margin:0 0 1em 0;}
#ygrp-tpmsgs{
font-family:Arial;
clear:both;}
#ygrp-vitnav{
padding-top:10px;font-family:Verdana;font-size:77%;margin:0;}
#ygrp-vitnav a{
padding:0 1px;}
#ygrp-actbar{
clear:both;margin:25px 0;white-space:nowrap;color:#666;text-align:right;}
#ygrp-actbar .left{
float:left;white-space:nowrap;}
.bld{font-weight:bold;}
#ygrp-grft{
font-family:Verdana;font-size:77%;padding:15px 0;}
#ygrp-ft{
font-family:verdana;font-size:77%;border-top:1px solid #666;
padding:5px 0;
}
#ygrp-mlmsg #logo{
padding-bottom:10px;}

#ygrp-vital{
background-color:#e0ecee;margin-bottom:20px;padding:2px 0 8px 8px;}
#ygrp-vital #vithd{
font-size:77%;font-family:Verdana;font-weight:bold;color:#333;text-transform:uppercase;}
#ygrp-vital ul{
padding:0;margin:2px 0;}
#ygrp-vital ul li{
list-style-type:none;clear:both;border:1px solid #e0ecee;
}
#ygrp-vital ul li .ct{
font-weight:bold;color:#ff7900;float:right;width:2em;text-align:right;padding-right:.5em;}
#ygrp-vital ul li .cat{
font-weight:bold;}
#ygrp-vital a {
text-decoration:none;}

#ygrp-vital a:hover{
text-decoration:underline;}

#ygrp-sponsor #hd{
color:#999;font-size:77%;}
#ygrp-sponsor #ov{
padding:6px 13px;background-color:#e0ecee;margin-bottom:20px;}
#ygrp-sponsor #ov ul{
padding:0 0 0 8px;margin:0;}
#ygrp-sponsor #ov li{
list-style-type:square;padding:6px 0;font-size:77%;}
#ygrp-sponsor #ov li a{
text-decoration:none;font-size:130%;}
#ygrp-sponsor #nc {
background-color:#eee;margin-bottom:20px;padding:0 8px;}
#ygrp-sponsor .ad{
padding:8px 0;}
#ygrp-sponsor .ad #hd1{
font-family:Arial;font-weight:bold;color:#628c2a;font-size:100%;line-height:122%;}
#ygrp-sponsor .ad a{
text-decoration:none;}
#ygrp-sponsor .ad a:hover{
text-decoration:underline;}
#ygrp-sponsor .ad p{
margin:0;}
o {font-size:0;}
.MsoNormal {
margin:0 0 0 0;}
#ygrp-text tt{
font-size:120%;}
blockquote{margin:0 0 0 4px;}
.replbq {margin:4;}
-->

__________________________________________________________
Don't get soaked. Take a quick peek at the forecast
with the Yahoo! Search weather shortcut.
http://tools.search.yahoo.com/shortcuts/#loc_weather

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity
Visit Your Group
Cool Websites

Know a good site?

Share and vote

on Bix.com!

Search Ads

Get new customers.

List your web site

in Yahoo! Search.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
Phlip | 20 Mar 2007 19:37
Picon
Gravatar

Re: [TFUI] Re: Is a bad test better than no test at all?

Tim Ottinger wrote:

> If the test runs quickly, returns true results (no tail chasing from false false negatives, no
misdirection through false positives), then keep it.

False negatives are okay if they are instant. You could learn from
your most recent edit and capture the issue with a test closer to the
source. And/or you can Undo to get rid of the failure and try a
simpler change.

 It's useful. If it sometimes returns false results or takes a long
time, then fuzzy is bad.
>
>  Ultimately, I fall back on Michael Feathers' "1) runs quickly, 2) helps to isolate errors". If it is too
fuzzy for either of the criteria, it's too fuzzy. Otherwise, not.

-- 
  Phlip
  http://c2.com/cgi/wiki?ZeekLand  <-- NOT a blog!!

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/testdrivendevelopment/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/testdrivendevelopment/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:testdrivendevelopment-digest <at> yahoogroups.com 
    mailto:testdrivendevelopment-fullfeatured <at> yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    testdrivendevelopment-unsubscribe <at> yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

amr_samadisy | 23 Mar 2007 03:59

[TFUI] ANN: Patterns of Agile Practice Adoption book available on InfoQ.com

<shameless plug>
I just wanted to let people know that InfoQ has just released the book
"Patterns of Agile Practice Adoption" and it is downloadable in
non-printable pdf format at
http://www.infoq.com/minibooks/agile-patterns. My completely unbiased
opinion is that this is an excellent read.
</shameless plug>

Amr

__._,_.___
Recent Activity
Visit Your Group
SPONSORED LINKS
Cool Websites

Know a good site?

Share and vote

on Bix.com!

Y! Toolbar

Get it Free!

easy 1-click access

to your groups.

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___
amr_samadisy | 23 Mar 2007 08:48

[TFUI] Re: ANN: Patterns of Agile Practice Adoption book available on InfoQ.com

Recent Activity
Visit Your Group
SPONSORED LINKS
Cool Websites

Know a good site?

Share and vote

on Bix.com!

Need traffic?

Drive customers

With search ads

on Yahoo!

Yahoo! Groups

Start a group

in 3 easy steps.

Connect with others.

.

__,_._,___

Gmane