ANN: a non-heinous acceptance test rig inside MiniRubyWiki

P

Phlip

Rubistas:

I have tuned my little Wiki to run acceptance tests. The "mini" in MRW
stands for "minimal dependencies". The Wiki works either with a raw Ruby
distribution alone, or with an additional CGI server, such as Apache.

Instructions on installing Apache appear here:

http://www.rubygarden.org/ruby?MiniRubyWiki/ApacheConfiguration

This documentation will cover only the CVS head. I have not yet productized
MRW, or wrapped things up into a new release.

Get a tarball of the head (you heard it here first, folks) from one of these
linkies:

http://rubyforge.org/cgi-bin/viewcvs.cgi/?cvsroot=minirubywiki

http://rubyforge.org/cgi-bin/viewcvs.cgi/cvs_root.tar.gz?tarball=1&cvsroot=minirubywiki

(Do not run the unit tests that come with MRW. They assume my environment.)

Now here's the non-heinous part. If you write nearly any XML (but with a
preference for one test case for each node at an XPath of '/*/*', and with
most data in attributes thereof), you can transclude that XML into the Wiki
with this statement:

!xml!myCommand!myPath/mySuite.xml

The first bang ! must appear in the leftmost column.

MRW uses a snip of XSLT to convert "any" XML into a list of forms. So given
this XML...

<suite>
<case input1='5' input2='3' action='product'>15</test>
<case result='pass' input1='8' input2='2' action='product'>16</test>
<case result='fail' input1='4'
input2='6' action='product'>2004</test>
</suite>

....MRW will display a Wiki page, and in the middle put a form like this:

suite
* case ---
action [ product ]
input1 [ 5 ]
input2 [ 3 ]
+----------------+
| 15 |
+----------------+
<Test> <Clone>

The [] are edit fields, and the 15 is inside a <textarea> representing the
<case> node's text
contents.

When you hit the Clone button, MRW will clone that node, so the XML will
then contain 4 nodes. (If the file is read-only, you get a little note
instead of the Test and Clone buttons.)

When you hit the Test button, MRW will save any changes from that form back
into its source XML, and will evaluate [the equivalent of] this command
line:

`myCommand mySuite.xml /suite/case[1]`

The last part is the XPath location of the node whose Test button you
selected. [Actually, the XPath is a more generic /*[1]/*[1], but you don't
need to know that.]

To test such a suite, you must write the program myCommand. You can write
that test fixture in any language you want - even (shocked gasp) a language
other than Ruby. It ought to provide these abilities:

- parse the XML file input
- select the node at the given XPath location
- "test" the node, by whatever means necessary
- write the result into a new node attribute, such as "result"
- save the XML file.

After myCommand evaluates, MRW reads the XML again, and displays it again.
Oh, and MRW also scrolls your web browser to the tested node, to maintain
your Flow.

Briefly, this Wiki permits you to test nodes, and clone-and-modify the
tests, without editing the raw Wiki pages. Only a tiny snip of XSLT is
required to convert XML into the XHTML forms required to edit that XML.

This system is online at my current gig, where I have found the need to
throw in just a few more tweaks. If a node contains an attribute called
"output", and if this contains the address of a GIF file, the Wiki will
transclude the result into its node's form:

http://www.c2.com/cgi/wiki?BroadbandFeedback

That screenshot shows result fields containing [ http:/files/filename.gif ].
The test fixture is responsible for reading that field and replacing the
http:/ part with the file path of your website when it saves the the GIF
file. I take screenshots from the test rig using a command-line program that
captures the topmost window, and I use ImageMagick to postprocess the image.

If you run this system under Apache, you must run that as a command-line
program, not a service.

In conclusion, this program has both extraordinary potential as a literate
acceptance test framework, but it has a very thin architecture. Hence its
learning curve is ... different. I'm interested in hearing if anyone wants
to be an early adopter, and use it to host their acceptance tests.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top