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 200931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:09:17+00:00 2026-05-11T17:09:17+00:00

Recently we have been adding automated tests to our existing java applications. What we

  • 0

Recently we have been adding automated tests to our existing java applications.

What we have

The majority of these tests are integration tests, which may cover a stack of calls like:-

  1. HTTP post into a servlet
  2. The servlet validates the request and calls the business layer
  3. The business layer does a bunch of stuff via hibernate etc and updates some database tables
  4. The servlet generates some XML, runs this through XSLT to produce response HTML.

We then verify that the servlet responded with the correct XML and that the correct rows exist in the database (our development Oracle instance). These rows are then deleted.

We also have a few smaller unit tests which check single method calls.

These tests are all run as part of our nightly (or adhoc) builds.

The Question

This seems good because we are checking the boundaries of our system: servlet request/response on one end and database on the other. If these work, then we are free to refactor or mess with anything inbetween and have some confidence that the servlet under test continues to work.

What problems are we likely to run into with this approach?

I can’t see how adding a bunch more unit tests on individual classes would help. Wouldn’t that make it harder to refactor as it’s much more likely we will need to throw away and re-write tests?

  • 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-11T17:09:17+00:00Added an answer on May 11, 2026 at 5:09 pm

    You are asking pros and cons of two different things (what are the pros and cons of riding a horse vs riding a motorcycle?)

    Of course both are “automated tests” (~riding) but that doesn’t mean that they are alternative (you don’t ride a horse for hundreds of miles, and you don’t ride a motorcycle in closed-to-vehicle muddy places)


    Unit Tests test the smallest unit of the code, usually a method. Each unit test is closely tied to the method it is testing, and if it’s well written it’s tied (almost) only with that.

    They are great to guide the design of new code and the refactoring of existing code. They are great to spot problems long before the system is ready for integration tests. Note that I wrote guide and all the Test Driven Development is about this word.

    It does not make any sense to have manual Unit Tests.

    What about refactoring, which seems to be your main concern? If you are refactoring just the implementation (content) of a method, but not its existence or “external behavior”, the Unit Test is still valid and incredibly useful (you cannot imagine how much useful until you try).

    If you are refactoring more aggressively, changing methods existence or behavior, then yes, you need to write a new Unit Test for each new method, and possibly throw away the old one. But writing the Unit Test, especially if you write it before the code itself, will help to clarify the design (i.e. what the method should do, and what it shouldn’t) without being confused by the implementation details (i.e. how the method should do the thing that it needs to do).


    Automated Integration Tests test the biggest unit of the code, usually the entire application.

    They are great to test use cases which you don’t want to test by hand. But you can also have manual Integration Tests, and they are as effective (only less convenient).


    Starting a new project today, it does not make any sense not to have Unit Tests, but I’d say that for an existing project like yours it does not make too much sense to write them for everything you already have and it’s working.

    In your case, I’d rather use a “middle ground” approach writing:

    1. smaller Integration Tests which only test the sections you are going to refactor. If you are refactoring the whole thing, then you can use your current Integration Tests, but if you are refactoring only -say- the XML generation, it does not make any sense to require the presence of the database, so I’d write a simple and small XML Integration Test.
    2. a bunch of Unit Tests for the new code you are going to write. As I already wrote above, Unit Tests will be ready as soon as you “mess with anything in between”, making sure that your “mess” is going somewhere.

    In fact your Integration Test will only make sure that your “mess” is not working (because at the beginning it will not work, right?) but it will not give you any clue on

    • why it is not working
    • if your debugging of the “mess” is really fixing something
    • if your debugging of the “mess” is breaking something else

    Integration Tests will only give the confirmation at the end if the whole change was successful (and the answer will be “no” for a long time). The Integration Tests will not give you any help during the refactoring itself, which will make it harder and possibly frustrating. You need Unit Tests for that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 393k
  • Answers 393k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When a large table is deleted or truncated InnoDB storage… May 15, 2026 at 1:55 am
  • Editorial Team
    Editorial Team added an answer See my changes in action: http://jsbin.com/ocovu/2/edit Here are the relevant… May 15, 2026 at 1:55 am
  • Editorial Team
    Editorial Team added an answer This won't work, as onmouseover does not fire on disabled… May 15, 2026 at 1:55 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.