Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4246400
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:58:05+00:00 2026-05-21T03:58:05+00:00

I have a task to write a set of http unit tests, which should

  • 0

I have a task to write a set of http unit tests, which should be deployed and started as single threaded application on external server.

After some investigation and reading of documentation I came to following application structure:

public static void main(String... args) throws Exception {

        Class[] testCases = {
                LoginTest.class,
                Test2.class,
                Test3.class
        };
        TestSuite suite = new TestSuite(testCases);

        TestResult result = new TestResult();
        suite.run(result);

        displayResults(result);
    }

And testcase looks like:

public class LoginPageTest extends TestCase {    
    public void testLogin() throws IOException, SAXException {

        WebConversation wc = new WebConversation();
        //Some HttpUnit init code here    

        loginForm.setParameter("j_username", login);
        loginForm.setParameter("j_password", pass);

        loginForm.submit();

        String expected = String.format("/%s/action/logon.do", endpoint); 

        assertEquals(wc.getCurrentPage().getURL().getPath(), expected);    
    }    
}

Has anyone made similar tasks ? Have you some advices than can improve this structure? How can I implement dependency between testcases (e.g. almost everything needs that user should be authenticated -> loginTestCase must be called) ?

Any advice greatly appreciated !

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T03:58:06+00:00Added an answer on May 21, 2026 at 3:58 am

    Currently I’ve found one appropriate way to design my testing application:

    TestCase class (extending jUnit):

    public class LogoutTest extends TestCase {
    
        public void testLogout() throws IOException, SAXException {
    
            new Config().initApplication()
                    .doLogin("user", "pass") // returns WelcomePage class
                    .goToFilterPage()  //Returns another page
                    .doLogout();  //returns LoginPage class
        }
       }
    

    After some time I’ve decided that it will be good to make for each page specific class which will have it’s specific control methods e.g. “go to next page”, “logout”, “click some button”, etc…

    public class WelcomePage extends AbstractPage  {
    
        protected WelcomePage(AbstractPage other) {
            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 FilterPage goToFilterPage() throws SAXException, IOException {
            WebLink link = webConversation.getCurrentPage().getLinkWithID("downloadLink");
            assertNotNull("Check if link exist on page", link);
            link.click();    
            return new FilterPage(this);
        }    
    }
    

    AbstractPage class (implements some common logic for all pages):

    public abstract class AbstractPage {
    
        protected WebConversation webConversation;
    
        protected Logger logger;
    
        protected AbstractPage(AbstractPage other) {
            this.webConversation = other.getWebConversation();
            this.logger = Logger.getLogger(this.getClass());
        }
    
        protected AbstractPage(WebConversation webConversation) {
            this.webConversation = webConversation;
            this.logger = Logger.getLogger(this.getClass());
        }
    
        public WebConversation getWebConversation() {
            return webConversation;
        }
    
        public void doLogout() throws SAXException, IOException {    
            WebLink logoutLink = webConversation.getCurrentPage().getLinkWithID("logoutLink");
            assertNotNull(logoutLink);
                logoutLink.click();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ant task set up like so: <target name=unit-test description=unit tests depends=compile-tests>
I have a c# multi-threaded monte carlo simulation , the application is already structured
I have a simple web control (TaskList) that can have children (Task) which inherit
Task: I have a camera mounted on the end of our assembly line, which
I've been given the following task: An external source will write a name, datetime
I have been set a task of natural language parsing in Prolog. So far
I'm working this programming task for college where we have to write a c++
I have a console MEF application which convert files. There are some classes for
I have this Task model: class Task < ActiveRecord::Base acts_as_tree :order => 'sort_order' end
I have a task and I want to generate some code using the CodeDom.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.