Integration TestingPage edited by DEMEY EmmanuelChanges (30)
Full ContentIntegration Testing with SeleniumThe Tapestry Test Utilities is a small library to make it easier to build integration test suites around Selenium version 1.0.3. The strategy is to start, in process, a Selenimum Server (which, in turn, starts and manages a web browser), a Jetty instance (for the web browser to talk to), and a Selenium client (which talks to the server). The client is able to request URLs, fill in form data, click links, and make assertions about output and behavior. UsageThe core part of this library is a base class for you to extend your tests classes : SeleniumTestCase. This class is responsible for starting an instance of Jetty to server your web application, as well as a copy of Selenium Server. It also implements the Selenium interface.
Here's an example from one of the Tapestry modules:
package org.apache.tapestry5.jpa.integration.app2;import org.apache.tapestry5.test.SeleniumTestCase; import org.testng.annotations.Test; public class SinglePersistenceUnitIntegrationTest extends SeleniumTestCase { @Test public void persist_entities() { open("/persistitem"); assertEquals(getText("//span[@id='name']").length(), 0); clickAndWait("link=create item"); assertText("//span[@id='name']", "name"); } } With the SeleniumTestCase class, you can use basic Selenium methods (such as open() and type()) and methods added by the SeleniumTestCase base class (clickAndWait() and assertFieldValue()). In addition, the SeleniumTestCase base class extends the normal exception reporting provided by Selenium; when a failure occurs inside Selenium server, a more detailed message, including the current page's HTML source, is reported to System.err. ConfigurationAll the configuration of your Integration Tests should be in your testng.xml file. Tapestry provides some parameters, in order to have the right environment for your tests.
Here's an example : <suite name="Selenium Tests Suite" annotations="1.5"> <test name="Integration Tests" enabled="true"> <parameter name="tapestry.browser-start-command" value="*googlechrome" /> <parameter name="tapestry.port" value="9091" /> <classes> <class name="com.example.newapp.SeleniumTest"></class> </classes> </test> </suite>
Change Notification Preferences
View Online
|
View Changes
|
- [CONF] Apache Tapestry > Integration Testing confluence
- [CONF] Apache Tapestry > Integration Testing confluence
- [CONF] Apache Tapestry > Integration Testing confluence
