HTML and CSS Reference
In-Depth Information
Listing 2.6
demonstrates a simple FitNesse test that checks the
http-equiv
meta tag in the head to make sure
it's properly specifying UTF-8. The first three lines set the classpath. Then, after a blank line, the next line
identifies the type of fixture as an HtmlFixture. (There are several other kinds, but HtmlFixture is the common
one for testing web applications.)
The external page at
http://www.elharo.com/blog/
is then loaded. In this page, we focus on the element named
meta
that has an
id
attribute with the value
charset
. This will be the subject for our tests.
The test then looks at two attributes of this element. First it inspects the
content
attribute and asserts that its
value is
text/html; charset=utf-8
. Next it checks the
http-equiv
attribute of the same element and asserts
that its value is
content-type
.
Listing 2.6. A FitNesse Test for <meta name="charset" http-equiv="Content-Type"
content="text/html; charset=UTF-8" />
!path fitnesse.jar
!path htmlunit-1.5/lib/*.jar
!path htmlfixture20050422.jar
!|com.jbergin.HtmlFixture|
|http://www.elharo.com/blog/|
|Element Focus|charset |meta|
|Attribute |content |text/html; charset=utf-8|
|Attribute |http-equiv|content-type|
This test would be embedded in a Wiki page. You can run it from a web browser just by clicking the Test button,
as shown in
Figure 2.4
. If all of the assertions pass, and if nothing else goes wrong, the test will appear green
after it is run. Otherwise, it will appear pink. You can use other Wiki markup elsewhere in the page to describe
the test.
Figure 2.4. A FitNesse page
[View full size image]
Search WWH ::
Custom Search