http://microformats.org/wiki/api.php?action=feedcontributions&user=AcelmOnouc&feedformat=atomMicroformats Wiki - User contributions [en]2024-03-29T08:50:41ZUser contributionsMediaWiki 1.38.4http://microformats.org/wiki/index.php?title=requirements-testing-examples&diff=35967requirements-testing-examples2008-12-20T03:30:11Z<p>AcelmOnouc: cocoricdr</p>
<hr />
<div>cnasitpasro<br />
== Requirements Testing Examples ==<br />
<br />
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:<br />
<br />
=== Feed Parser Test Suite ===<br />
<br />
The XML files from the [http://feedparser.org/tests/ 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:<br />
<br />
<pre><br />
<!--<br />
Description: Atom namespace (official)<br />
Expect: bozo and feed['title'] == u'Example Atom'<br />
--><br />
<br />
<!--<br />
Description: entry contributor homepage<br />
Expect: bozo and entries[0]['contributors'][0]['url'] == u'http://example.com/'<br />
--><br />
</pre><br />
<br />
=== Canoo WebTest ===<br />
<br />
[http://webtest.canoo.com/manual/WebTestHome.html Canoo WebTest] runs test steps defined in the Ant XML format:<br />
<br />
<pre><br />
<target name="login" > <br />
<webtest name="normal" ><br />
&config;<br />
<steps><br />
<invoke description="get Login Page"<br />
url="login.jsp" /><br />
<verifyTitle description="we should see the login title" <br />
text="Login Page" /><br />
<setInputField description="set user name" <br />
name="username"<br />
value="scott" /><br />
<setInputField description="set password" <br />
name="password"<br />
value="tiger" /><br />
<clickButton description="Click the submit button" <br />
label="let me in" /><br />
<verifyTitle description="Home Page follows if login ok"<br />
text="Home Page" /><br />
</steps><br />
</webtest><br />
</target><br />
</pre><br />
<br />
=== Selenium ===<br />
<br />
[http://selenium.thoughtworks.com/ 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:<br />
<br />
<pre><br />
open<br />
click<br />
clickAndWait<br />
verifyTitle<br />
verifyValue<br />
</pre><br />
<br />
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:<br />
<br />
<pre><br />
<table cellpadding="1" cellspacing="1" border="1"><br />
<tbody><br />
<tr><br />
<td rowspan="1" colspan="3">Test Select<br><br />
</td><br />
</tr><br />
<tr><br />
<td>open</td><br />
<td>./tests/html/test_select.html</td><br />
<td>&nbsp;</td><br />
</tr><br />
<tr><br />
<td>select</td><br />
<td>theSelect</td><br />
<td>index=4</td><br />
</tr><br />
<tr><br />
<td>verifySelected</td><br />
<td>theSelect</td><br />
<td>Fifth Option</td><br />
</tr><br />
</tbody><br />
</table><br />
</pre><br />
<br />
There are no specific semantic attributes used - the test tool simply extracts commands from the columns of the table.<br />
<br />
=== Watir ===<br />
<br />
[http://wtr.rubyforge.org Watir] is a testing tool, written in Ruby that implements a domain specific language for driving web tests with Internet Explorer.<br />
<br />
Example (using the browser):<br />
<br />
<pre><br />
ie = IE.new<br />
ie.goto("http://microformats.org")<br />
ie.contains_text("Designed for humans first")<br />
</pre><br />
<br />
Example (clicking a link):<br />
<br />
<pre><br />
ie.link(:text, "Microformats").click<br />
</pre><br />
<br />
Would click the hyperlink:<br />
<br />
<pre><br />
<a href="http://microformats.org">Microformats</a><br />
</pre></div>AcelmOnouc