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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:24:41+00:00 2026-06-04T09:24:41+00:00

I’m setting up some test scaffolding around an existing project. This includes some integration

  • 0

I’m setting up some test scaffolding around an existing project. This includes some integration tests, using JUnit and DbUnit. I’ve also set up a Jenkins installation for continuous integration.

My problem involves changing the DB connections between the development and testing environments. I have my own product stack installed locally for quick ad-hoc testing and investigation. As I’m developing, I run tests against my private database, since it’s faster and I won’t ruin anybody else’s day with buggy work-in-progress code.

Once code is checked in, Jenkins will run my tests. Right now it’s still pointing at my local db. I’d prefer to have Jenkins run tests against a different database, one that is in the test environment.

Is there a best practice / strategy / technology / etc. for changing database connections for testing without having to change code? Bonus points if the solution allows Jenkins to run the same tests against multiple DBs (should be possible since DbUnit is agnostic).


Edits for more info:

The product is a large one, with dozens of different interacting components (usually in separate vms / processes). In a live system, the different processes typically communicate through the database. IE, the UI process writes changes to a table and the back-end process polls that table for changes. Yes, it’s awful. For integration testing, I configure a system using the UI and capture that state with DbUnit. I can then run tests against that “input.”

My component, and all new components, are managed by maven. DB Connections are currently hard-coded in the test setup. The DbUnit system works; I’d just like to be able to switch which database my tests are referencing depending on whether they’re being run by me in my development environment, or run by Jenkins in the testing environment.

  • 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-04T09:24:42+00:00Added an answer on June 4, 2026 at 9:24 am

    Assuming that you can externalise the database connectivity parameters for your tests into a .properties or .xml file, and that you are using Maven, then one approach is to use Maven properties (and optionally profiles) to define each environment, and use resource filtering to configure these properties into your configuration file.

    For example, suppose during testing that you manage to externalise your database connectivity parameters into a file called datasource.properties in src/test/resources that looks like this:

    datasource.driverClassName = ${test.datasource.driverClassName}
    datasource.url = ${test.datasource.url}
    datasource.username = ${test.datasource.username}
    datasource.password = ${test.datasource.password}
    

    And you have this in your POM:

    <build>
      <testResources>
        <testResource>
          <directory>src/test/resources</directory>
          <filtering>true</filtering>
        </testResource>
      </testResources>
    </build>
    

    Then you could define test.datasource.driverClassName etc. properties in various ways to tell Maven to use different databases:

    • You could define defaults in the <properties> section of your POM;
    • You could define user-specific databases in the <properties> section of each developer’s (and Jenkins’) settings.xml;
    • You could define some profiles in your POM for different environments (e.g. development, jenkins, anotherDB) and run your build with different profiles.

    If you go for the last option, then you could get Jenkins to run against multiple databases by performing multiple Maven builds from one Jenkins project, differing only by profile. That said, it would be better to have different Jenkins project for each environment.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.