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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:35:25+00:00 2026-06-18T09:35:25+00:00

I have a class that extends the JUnit TestCase class. The test has a

  • 0

I have a class that extends the JUnit TestCase class. The test has a number of ‘setup’ routines that need to be executed. One of these routines is to insert some data into a database for example, another is to send JMS messages onto EMS queues.

Currently, all of this functionality is inside the overridden setUp method in the test class. However, there must be a better way of doing this. I’d possibly want to use dependency injection also to make the test class more generic.

Thanks.

  • 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-06-18T09:35:26+00:00Added an answer on June 18, 2026 at 9:35 am

    I don’t think dependency injection is (necessarily) the answer unless you plan on writing tests for your test cases. If I were you I’d do the simplest thing possible and that is to extract this setup code into classes. For example, a JmsSetup class and a DatabaseSetup class. Have your setup method create and use these classes.

    Take it from there, if that starts to get messy you can do more but don’t cross that bridge until you get to it.

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

Sidebar

Related Questions

I have a simple JUnit test in Eclipse. public class HelloTest extends TestCase {
I have class that extends Activity. That has a Logout menu options. When I
I have a class that extends AsyncTask , which fetches the gps cordinates from
I have a class that extends Application. The class is fairly extensive. When the
I have a class that extends View. I override the onDraw method and allow
I have a class that extends android.app.Dialog, the layout is done in an xml
i have a class that extends another. when i iterate the current object i
I have a class that extends AsyncTask. In the doInBackground() method, I connect to
I have a class that extends JPanel. On the panel I have added an
In my Android app, I have a class that extends Thread that runs when

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.