[Lipog-commit] net.heilancoo.portal.documentation/doc apptest-123.html, NONE, 1.1 index.html, 1.19,
Status: Beta
Brought to you by:
jbu
From: Joerg B. <jb...@us...> - 2009-07-26 16:47:47
|
Update of /cvsroot/lipog/net.heilancoo.portal.documentation/doc In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv15149/doc Modified Files: index.html Added Files: apptest-123.html Log Message: web application test tutorial --- NEW FILE: apptest-123.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Automated Web Application Testing with the Gizmo</title> </head> <body> <link rel="stylesheet" type="text/css" href="default.css" /> <p><a href="index.html">Home of Little Portal Gizmo</a></p> <h1>Automated Web Application Testing with the Gizmo</h1> <p>This short tutorial should see you through the basic steps necessary to to create automated tests for your web application. We use the bingo plug-in project that was created in the <a href="webapp-123.html">Creating a Web Application with the Gizmo</a> tutorial. So we assume your development workspace is set up and contains the Gizmo plug-ins and the bingo web application plug-in. <p> <h2>Create a Fragment Project for the Tests</h2> <p>Invoke the "File > New... > Project..." command. This will bring the following dialog to the screen.</p> <img src="snaps/new-test-fragment-1.png"> <p>Select "Fragment Project" from the "Plug-in Development" category. Then click "Next."</p> <img src="snaps/new-test-fragment-2.png"> <p>In the "Fragment Project" dialog fill in the project name (here "net.heilancoo.bingo.test") and click "Next."</p> <img src="snaps/new-test-fragment-3.png"> <p>In the "Fragment Content" dialog, fill in "net.heilancoo.bingo" as host plug-in id (and add a few other details as shown in the screen shot above. Then click "Finish" to create the project.</p> <h2>Add Dependency to the Test Fragment</h2> <p>Add plug-in "net.heilancoo.portal.testutils" as a dependency to the bingo test fragment.</p> <img src="snaps/test-fragment-dependency-1.png"> <h2>Add Test Code</h2> <p>Create Java package "net.heilancoo.bingo.test"</p> <p>Create a JUnit test class:</p> <img src="snaps/test-fragment-junit-test-case-1.png"> <p>Clicking "Finish" in the above dialog will create test case file content like this:</p> <pre> public class BingoApp { @BeforeClass public static void setUpBeforeClass() throws Exception { } } </pre> <p>Add a call to start the Gizmo web apps so that the file looks like this:</p> <pre> public class BingoApp { @BeforeClass public static void setUpBeforeClass() throws Exception { PortalTest.startPortal(500); } } </pre> <p>This will start the web application in the background and wait 500 ms before returning.</p> <p>Now add a test.</p> <pre> public class BingoApp { @BeforeClass public static void setUpBeforeClass() throws Exception { PortalTest.startPortal(500); } @Test public void doLoginTest() throws FailingHttpStatusCodeException, MalformedURLException, IOException, SessionException, ApplicationException { // =========================================================== // Log into the web application. This is client side activity. WebClient cl = new WebClient(); HtmlPage pg = cl.getPage("http://127.0.0.1:8080/bingo"); assertEquals("Login", pg.getTitleText()); HtmlForm login = pg.getFormByName("input"); login.getInputByName("user").setValueAttribute("joerg"); login.getInputByName("password").setValueAttribute("joerg"); HtmlPage loggedIn = login.getInputByName("button").click(); // ========================================================== // Now peep directly into the server side of the application: BingoSession s = (BingoSession) PortalTest.getSessionForPage(loggedIn); assertEquals(1, s.getAccessCounter()); // ===================================================== // Back on the client side. Continue with some activity. loggedIn.getAnchorByHref("main").click(); // ================================== // And again inspect the server side: assertEquals(2, s.getAccessCounter()); } } </pre> <h2>Create a Run Configuration to Execute the Test</h2> <p>Use the "Run > Run configurations..." command to bring up the run configurations management dialog.</p> <img src="snaps/test-run-configuration-1.png"> <p>Press the "New launch configuration" button in the launch configuration dialog and you should see a lauch configuration like the one in the screen shot below.</p> <img src="snaps/test-run-configuration-2.png"> <p>Press the "Run" button to run the test. The test should succeed.</p> <p class="revinfo"> <div id="rev">$Revision: 1.1 $</div> <div id="date">$Date: 2009/07/26 16:47:39 $</div> <div id="auth">$Author: jbu $</div> </p> <a href="http://sourceforge.net/projects/lipog"> <img src="http://sflogo.sourceforge.net/sflogo.php?group_id=257822&type=16" border="0" width="150" height="40" alt="Get Little Portal Gizmo at SourceForge.net. Fast, secure and Free Open Source software downloads" /></a> </body> </html> Index: index.html =================================================================== RCS file: /cvsroot/lipog/net.heilancoo.portal.documentation/doc/index.html,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** index.html 25 Jul 2009 06:26:24 -0000 1.19 --- index.html 26 Jul 2009 16:47:39 -0000 1.20 *************** *** 32,36 **** <ul> <li>have as few lines of code and configuration as possible in applications </li> ! <li>automatic decoding of parameters in HTTP PUT and GET requests</li> <li>be able to serve static content</li> <li>straightforward integrated session handling</li> --- 32,36 ---- <ul> <li>have as few lines of code and configuration as possible in applications </li> ! <li>automatic decoding of parameters in HTTP POST and GET requests</li> <li>be able to serve static content</li> <li>straightforward integrated session handling</li> *************** *** 119,122 **** --- 119,123 ---- <ul> <li><a href="webapp-123.html">Web Application</a></li> + <li><a href="apptest-123.html">Web Application Testing</a></li> <li><a href="product-123.html">Deployment</a></li> <li><a href="webfolder-123.html">Web Folder</a></li> |