One of the goals of an agile web software development team is to
deliver quality software in a timely fashion. For most web
applications the server-side software uses a database and the final
products are HTML and/or XML. HTML is rendered by a browser and XML
is either processed by a browser (AJAX) or exchanged with a partner
web application (business-to-business integration). Fitnesse tests can communicate with
the database and can make assertions against HTML and XML. Agile
web teams can use Fitnesse to create comprehensive test suites that
make system-level assertions. Once these test suites exist, the team
can release updates to their production web site as often as every
day, confident that all of the system-level requirements (both old
and new) are being met.
The purpose of this article is to illustrate the use of Fitnesse
by agile web development teams. It first will discuss some of the
reasons that agile web development teams would want to adopt a
rapid release schedule. Next it will suggest that Fitnesse is a
viable testing tool for use with this schedule. Then it will
provide a number of examples to demonstrate the simplicity and
power of Fitnesse. Finally, it will provide tips regarding Fitnesse
test writing.
In this article, the agile term "whole team" refers to the
collective group of software developers, DBAs, technical testers,
managers, and customers. Agile software development is a
discipline. For more information regarding agile software
methodologies, see Ron Jeffries's XP web
site.
Why Would a Development Team Release Software Updates Every
Day?
Short answer: Good for the business.
The company's product is an e-product.
Super-short releases allow the marketing department to obtain rapid
customer feedback and to respond to that feedback quickly. They can
test modifications to existing products and release new products
sooner and more often. The agile concept of rapid feedback works
well for the marketing team, too!
It's good for search engine optimization.
Frequently updated web sites perform better in organic search
engine results. This enables the business to attract customers to
its web site without paying for sponsored links.
To respond to changing customer needs. Businesses
that support diverse customer niches demand more agility from their
products.
For contractual agreements with e-partners.
Contractual agreements involving business-to-business web site
integration can dictate when the software is released.
The rapid release schedule accommodates a wide range of sizes
and types of projects, because each day the whole team has the
opportunity to release software updates, regardless of how long the
updates took to develop. Although the whole team could probably get
by without releasing its software quite as often, once a rapid
release schedule is adopted, the team members will wonder how they
ever managed without it.
Simple web sites can be managed effectively by a content
management system and require little developer, DBA, and technical
tester work. However, more complex web sites require software
customizations to provide tracking services for their e-products.
This tracking can include page impressions, clicked links, dynamic
advertising, and links to partner sites, which can then be customized
for each e-product. These types of requirements are dynamic enough
to keep patterns in the software design from forming, thereby
forcing the whole team to release new products more often.
Why Fitnesse?
It's easy to use. Web developers, DBAs, technical
testers, managers, and customers can all learn how to use wiki
markup to make test assertions.
It's easy to install and lightweight to run. Get
started with Fitnesse by running it on a developer
workstation.
It performs assertions against HTML, XML, Java, and the
database, all from a single tool. The complexity of your
requirements will not outgrow Fitnesse's capabilities, because it
can be extended to test anything testable with Java. Test writing
is limited only by the whole team's imagination.
It's open source and well documented.
Agile web developers write Java software to test their Java
objects, web pages, databases, and XML documents. JUnit is a popular testing framework
for regression testing Java technologies. Fitnesse is analogous to
JUnit in that it is a testing engine built using Java technologies.
However, Fitnesse is different because its user interface is a web
application with test suites created and managed using wiki
markup. The key difference is that JUnit is primarily used by
developers, whereas Fitnesse's user interface is friendly to
non-developers, too. The developer extends Fitnesse's testing
engine to expose new assertion methods. Then any team member
(technical or not) can use the wiki markup to populate and run
these new assertion methods. In the end, the developers use both
JUnit and Fitnesse; each for different purposes.
Fitnesse describes itself as a "fully integrated standalone
wiki, and acceptance testing framework" that runs test assertions
using wiki markup. The wiki markup is used to create test tables
whose assertions are run inside of the Java web FitServer. Upon
completion of the test table, the FitServer displays a green-colored cell for each correct assertion and a red-colored cell for
each failed assertion.
A fixture is a
Java class that parses a wiki test table and then connects the test
table to methods in the Java class. Fixtures support input
parameters and connect a method's output to the wiki's display. For
teams that want to quickly get started, there are HTML and database
fixtures that can
be installed and used without customization. For teams that need
more functionality, the complexity of the assertions is limited
only by the whole team's time and imagination, because Fitnesse's
Java test fixtures are meant to be extended and customized. For
instance, the developer team can write Java software that queries a
database and then uses that data to assert that a web page is
rendering that data correctly in HTML or XML.
HtmlFixture Asserting Text and Links Are Correct
Project requirements:
Create a home page with title, meta-keywords, and a meta-description.
Create a "Daily News" page with title, meta-keywords, and a meta-description.
Create a link from the home page to the "Daily News" page.
Use the mock-up in Figure 1 to create the display.
Figure 1. Mock-up of horizontal navigation including the "Daily
News" link
The HtmlFixture test table below loads a web page,
asserts that the title and meta tags are correct, asserts that the
"Daily News" display text and URL are correct, and then clicks on
the link to prove that it works. Use Fitnesse markup variables
to define the HtmlFixture's URL. This will allow you
to quickly toggle the environment (develop, test, production) being
tested. The domain markup variable is defined in the
root suite so that the test runner can control which environment
all of the HTML tests will run against.
!define domain {www.jhound.com}
Also, give each tested HTML element a unique id tag
so that the Element Focus command can be used to find
and focus on the element.