java - Best design to organize HttpUnit+junit as standalone app -


I have to write a set of HTP unit tests, which should be deployed and on the external server as a single threaded application Should start.

After reading some investigations and documentation, I came to the following application structure:

  Public static zero master throws exception (class ... args) {class [] Test Cases = {LogInsthest. Class, Test 2 Class, Test 3 Class}; TestSuite suite = New TestSuite (Testcases); TestResult Results = New TestResult (); Suite.run (results); DisplayResults (results); } And testcase looks like this:  
  extends the public class LoginPageTest TestCase {Public Zero testLogin () throws IOException, SAXException {WebConversation wc = New WebConversation (); // something HttpUnit init code here loginForm.setParameter ("j_username", login); LoginForm.setParameter ("j_password", pass); LoginForm.submit (); String Expected = String. Format ("/% s ​​/ verb / logon.", Endpoint); AssertEquals (wc.getCurrentPage (). GetURL (). GetPath (), expected); }}   

Has anyone done similar work? Can you take some advice compared to improving this structure? How can I apply dependency between trial cases (for example, almost everything needs that the user should be certified - & gt; LoginTestCase should be called)?

Any advice much appreciated!

Thanks in advance.

Currently I have found a proper way to design my test application: < P> Tests classes (Expanding jUnit):

  Public class logout throws a test test season (Public Zero Testing Layout), throws IOException, SAXException {new config (). InitApplication (). Do not login ("user", "pass") // return welcome page class .goToFilterPage () // returns another page. DOLogout (); // Return log-in class}}   

After some time, I have decided that it would be good for each page specific class to have an example of specific control methods. "On the next page Go "," logout "," click on some button ", etc ...

  Extension of the public category welcome page (protected page) (other abstract page) {super (other ); String Expected = String.format ("/% s ​​/ welcome.do", Config.endpoint); AssertEquals (expected, webConversation.getCurrentPage (). GetURL (). GetPath ()); Logger.info (String.format ("current page:% s", webConversation.getCurrentPage (). GetURL (). GetPath ())); } Public filter page throws GoToFilterPage () SAXException, IOException {WebLink link = webConversation.getCurrentPage (). GetLinkWithID ("downloadLink"); AssertNotNull ("Check that the link exists on the page", link); Link.click (); Return new filter page (this); Summary page range (applies some common logic for all pages):  
  Public abstract class abstract page [protected WebConversation webConversation; Protected logger logger; Protected Sarpage (abstract page other) {this.webConversation = other.getWebConversation (); This.logger = Logger.getLogger (this.getClass ()); } Secure Essence Page (Web Convergence Web Conversions) {this.webConversation = webConversation; This.logger = Logger.getLogger (this.getClass ()); } Public WebConversation getWebConversation () {return webConversation; } Public Zero doLogout () throws SAXException, IOException {WebLink logout links = web conversion. GetCurrentPage () GetLinkWithID ("Logout Link"); AssertNotNull (logoutLink); LogoutLink.click (); }}    

Comments