ANN: a non-heinous acceptance test rig inside MiniRubyWiki

Discussion in 'Ruby' started by Phlip, Nov 27, 2004.

  1. Phlip

    Phlip Guest


    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:

    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

    (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:


    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...

    <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>

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

    * 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

    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

    `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:

    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.

    Phlip, Nov 27, 2004
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tim Williams

    SMTP Test Rig ( SMTPRIG.PY v1.0 )

    Tim Williams, Jun 10, 2005, in forum: Python
    Jun 12, 2005
  2. Steve Jorgensen

    Acceptance test spike example

    Steve Jorgensen, Jun 27, 2005, in forum: Python
    Steve Jorgensen
    Jun 30, 2005
  3. The Eternal Squire

    where can I find Python acceptance test suite?

    The Eternal Squire, Aug 6, 2006, in forum: Python
    The Eternal Squire
    Aug 7, 2006
  4. Phlip
    Apr 20, 2004
  5. Phlip

    ANN: MiniRubyWiki 1.0.0

    Phlip, Apr 1, 2005, in forum: Ruby
    Lyle Johnson
    Apr 2, 2005

Share This Page