<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>A Public Scratchpad &#187; JWebUnit</title>
	<atom:link href="http://daniel.gredler.net/category/jwebunit/feed/" rel="self" type="application/rss+xml" />
	<link>http://daniel.gredler.net</link>
	<description></description>
	<lastBuildDate>Tue, 24 Jan 2012 01:02:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='daniel.gredler.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>A Public Scratchpad &#187; JWebUnit</title>
		<link>http://daniel.gredler.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://daniel.gredler.net/osd.xml" title="A Public Scratchpad" />
	<atom:link rel='hub' href='http://daniel.gredler.net/?pushpress=hub'/>
		<item>
		<title>Assertions in HtmlUnit</title>
		<link>http://daniel.gredler.net/2007/10/15/assertions-in-htmlunit/</link>
		<comments>http://daniel.gredler.net/2007/10/15/assertions-in-htmlunit/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 00:30:05 +0000</pubDate>
		<dc:creator>Daniel Gredler</dc:creator>
				<category><![CDATA[HtmlUnit]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JWebUnit]]></category>

		<guid isPermaLink="false">http://daniel.gredler.net/2007/10/15/assertions-in-htmlunit/</guid>
		<description><![CDATA[I&#8217;ve been going back through the pros and cons of JWebUnit as part of my research for the HtmlUnit vs Foo series of articles I&#8217;m writing. One of JWebUnit&#8217;s big draws is the set of easy-to-use assertion methods provided by its base test case class, WebTestCase. HtmlUnit doesn&#8217;t provide such a thing, because it doesn&#8217;t [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daniel.gredler.net&amp;blog=887150&amp;post=34&amp;subd=gredler&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been going back through the pros and cons of <a href="http://jwebunit.sourceforge.net/">JWebUnit</a> as part of my research for the <em>HtmlUnit vs Foo</em> series of <a href="http://daniel.gredler.net/2007/10/04/htmlunit-vs-httpunit/">articles</a> I&#8217;m writing. One of JWebUnit&#8217;s big draws is the set of easy-to-use assertion methods provided by its base test case class, <a href="http://jwebunit.sourceforge.net/2.x/apidocs/net/sourceforge/jwebunit/WebTestCase.html">WebTestCase</a>. HtmlUnit doesn&#8217;t provide such a thing, because it doesn&#8217;t provide a base test case class.</p>
<p>There has always been something of a trade-off here: use JWebUnit and tie yourself to a specific unit testing framework (JUnit) while benefiting from a more domain-specific set of assertions (<em>assertCookiePresent</em>, <em>assertFormPresent</em>,  <em>assertLinkPresent</em>, etc), or fly free with HtmlUnit but perform assertions using only the primitive utility methods provided by your unit testing framework (<em>assertNull</em>, <em>assertNotNull</em>, <em>assertEquals</em>, etc).</p>
<p>However, I&#8217;ve long though that it would be nice for HtmlUnit to have the best of both worlds by using an assertion utility class, similar to TestNG&#8217;s <a href="http://testng.org/javadocs/org/testng/Assert.html">Assert</a> class. Experiencing the convenience of JWebUnit&#8217;s API again has given me the final kick in the pants, and the first version of HtmlUnit&#8217;s new <a href="http://htmlunit.svn.sourceforge.net/viewvc/htmlunit/trunk/htmlunit/src/java/com/gargoylesoftware/htmlunit/WebAssert.java?view=markup">WebAssert</a> class is now in SVN. It will be included as part of HtmlUnit 1.14, or you can always grab the latest build <a href="http://build.canoo.com/htmlunit/artifacts/">here</a>. I&#8217;m sure the set of available assertions will grow, but here is the initial list:</p>
<ul>
<li>assertTitleEquals(HtmlPage, String)</li>
<li>assertTitleContains(HtmlPage, String)</li>
<li>assertTitleMatches(HtmlPage, String)</li>
<li>assertElementPresent(HtmlPage, String)</li>
<li>assertElementPresentByXPath(HtmlPage, String)</li>
<li>assertElementNotPresent(HtmlPage, String)</li>
<li>assertElementNotPresentByXPath(HtmlPage, String)</li>
<li>assertTextPresent(HtmlPage, String)</li>
<li>assertTextPresentInElement(HtmlPage, String, String)</li>
<li>assertTextNotPresent(HtmlPage, String)</li>
<li>assertTextNotPresentInElement(HtmlPage, String, String)</li>
<li>assertLinkPresent(HtmlPage, String)</li>
<li>assertLinkNotPresent(HtmlPage, String)</li>
<li>assertLinkPresentWithText(HtmlPage, String)</li>
<li>assertLinkNotPresentWithText(HtmlPage, String)</li>
<li>assertFormPresent(HtmlPage, String)</li>
<li>assertFormNotPresent(HtmlPage, String)</li>
<li>assertInputPresent(HtmlPage, String)</li>
<li>assertInputNotPresent(HtmlPage, String)</li>
<li>assertInputContainsValue(HtmlPage, String, String)</li>
<li>assertInputDoesNotContainValue(HtmlPage, String, String)</li>
</ul>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gredler.wordpress.com/34/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gredler.wordpress.com/34/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gredler.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gredler.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gredler.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gredler.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gredler.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gredler.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gredler.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gredler.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gredler.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gredler.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gredler.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gredler.wordpress.com/34/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gredler.wordpress.com/34/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gredler.wordpress.com/34/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=daniel.gredler.net&amp;blog=887150&amp;post=34&amp;subd=gredler&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://daniel.gredler.net/2007/10/15/assertions-in-htmlunit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d71895d31422ff2da109a665d5f6d256?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gredler</media:title>
		</media:content>
	</item>
	</channel>
</rss>
