Information Technology Reference
In-Depth Information
LISTING 6-5
System Test Using JWebUnit
public class LoginTest extends WebTestCase {
protected void setUp() throws Exception {
getTestContext().
setBaseUrl("http://pone.acme.com/meinst/");
}
public void testLogIn() {
beginAt("/");
setFormElement("j_username", "aader");
setFormElement("j_password", "a1445");
submit();
assertTextPresent("Logged in as aader");
}
}
Automate Functional Tests
Functional tests, as the name implies, test the functionality of an
application from the viewpoint of a client, which means the tests them-
selves mimic clients. These tests are also known as acceptance tests.
As mentioned earlier, frameworks like Selenium actually control a
browser and enable it to interact with a Web site. Selenium tests are
written in tabular forms, which represent a work flow, complete with
commands and assertions. The code in Listing 6-6 is a Selenium test
case that attempts a Web site login and then verifies if the attempt was
successful.
LISTING 6-6
Functional Test Using Selenium
TestLoginSuccess
open
/ib/app
verifyTitle
Integrate Button - Welcome
verifyTextPresent
Welcome to The IntegrateButton.com.
Please log in to access exclusive
material for the topic.
clickAndWait
link=Log In
type
inputUserId
admin
type
inputPassword
admin
clickAndWait
loginSubmit
assertTextPresent
Logout
 
Search WWH ::




Custom Search