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

  • SEARCH
  • Home
  • 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 7672367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:16:09+00:00 2026-05-31T16:16:09+00:00

I have a really long integration test that simulates a sequential process involving many

  • 0

I have a really long integration test that simulates a sequential process involving many different interactions with a couple of Java servlets. The servlets’ behavior depends on the values of the parameters being posted in the request, so I wanted to test every permutation to make sure my servlets are behaving as expected.

Currently, my integration test is in one long function called “testServletFunctionality()” that goes something like this:

//Configure a mock request
//Post request to servlet X
//Check database for expected changes
//Re-configure mock request
//Re-post request to servlet X
//Check database for expected changes
//Re-configure mock request
//Post request to servlet Y
//Check database for expected changes
...

and each configure/post/check step has about 20 lines of code, so the function is very long.

What is the proper way to break up or organize a long, sequential, repetitive integration tests like this?

  • 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-31T16:16:10+00:00Added an answer on May 31, 2026 at 4:16 pm

    The main problem with integration tests (IT) is usually that the setup is very expensive. Tests usually should not depend on each other and the order in which they are executed but for ITs, test #2 will always fail if you don’t run test #1 (login).

    Sad.

    The solution is to treat these tests like production code: Split long methods into several smaller ones, build helper objects that perform certain operations, so you can do this in your test:

    @Test
    public void someComplexText() throws Exception {
        new LoginHelper().loginAsAdmin();
        ....
    }
    

    or move this code into a base test class:

    @Test
    public void someComplexText() throws Exception {
        loginHelper().loginAsAdmin();
        ....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of Visual Studio Team System unit (integration really) tests that
I have a really long 3 column table. I would like to <table> <tr><td>Column1</td><td>Column2</td></tr>
I have a really long port map where I want to replace a bunch
I have a block of text which occasionally has a really long word/web address
I have this case <WrapPanel> <CheckBox>Really long name</CheckBox> <CheckBox>Short</CheckBox> <CheckBox>Longer again</CheckBox> <CheckBox>Foo</CheckBox> <Slider MinWidth=200
I have a rather long switch-case statement. Some of the cases are really short
Apologies in advance for the long-winded question. I'm really a database programmer, but have
If you have written a really long command, say cd /very/long/path , and then
I have a c++ program which takes really long time to run in cygwin
i have the following situation. I'm having a really long webpage where I want

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.