From Microformats Wiki
Jump to navigation Jump to search

Requirements Testing Examples

The XUnit framework approach to writing test cases is still the most common way of implementing automated tests, but there are already a number of examples of mini languages and formats for web testing:

Feed Parser Test Suite

The XML files from the Feed Parser Test Suite created by Mark Pilgrim are prefixed with a comment containing a description and expectation, decoupling the test assertions from imperative code:

Description: Atom namespace (official)
Expect:      bozo and feed['title'] == u'Example Atom'

Description: entry contributor homepage
Expect:      bozo and entries[0]['contributors'][0]['url'] == u''

Canoo WebTest

Canoo WebTest runs test steps defined in the Ant XML format:

 <target name="login" > 
  <webtest name="normal" >
      <invoke        description="get Login Page"
        url="login.jsp"   />
      <verifyTitle   description="we should see the login title" 
        text="Login Page" />
      <setInputField description="set user name" 
        value="scott"     />
      <setInputField description="set password" 
        value="tiger"     />
      <clickButton   description="Click the submit button" 
        label="let me in" />
      <verifyTitle   description="Home Page follows if login ok"
        text="Home Page"  />


Selenium is a Javascript based testing agent that runs a set of commands on a target website using a mini language for binding actions and assertions to page elements and DOM selections. Basic commands include:


Selenium test commands are defined using arbitrary HTML tables. This example is from the basic tests shipped with the framework, and shows how to specifiy assertions against an HTML select element:

 <table cellpadding="1" cellspacing="1" border="1">
      <td rowspan="1" colspan="3">Test Select<br>
      <td> </td>
      <td>Fifth Option</td>

There are no specific semantic attributes used - the test tool simply extracts commands from the columns of the table.


Watir is a testing tool, written in Ruby that implements a domain specific language for driving web tests with Internet Explorer.

Example (using the browser):

 ie =
 ie.contains_text("Designed for humans first")

Example (clicking a link):, "Microformats").click

Would click the hyperlink:

 <a href="">Microformats</a>