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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:31:06+00:00 2026-06-18T06:31:06+00:00

When testing with spring and @ContextConfiguration Is there an option to exclude some of

  • 0

When testing with spring and @ContextConfiguration
Is there an option to exclude some of the base class contexts?
for example

@ContextConfiguration(locations = {"context1.xml", "context2.xml"})
public class Base{

and extending class

public class someClass extends Base{

now I want someClass to use context1.xml but NOT context2.xml. is there a way to exclude it?
the issue is: I have a base class for all my tests (300 tests). I want all of them to use context1 which is a mock context that overrides the original one. Only one class should use the original context in order to test it (if the Base will not have it in its locations{} it will use the original).

  • 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-18T06:31:07+00:00Added an answer on June 18, 2026 at 6:31 am

    As already mentioned, excluding contexts will not be possible.

    However, I would advise you to take a look at the new Spring 3 bean profiles.

    By specifying / activating the correct profiles you should be able to achieve the same thing in a cleaner way…

    A nice article on unit / integration testing with spring bean profiles can be found here.

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

Sidebar

Related Questions

I am doing some testing with Spring Tool Suite to familiarize my self with
Can you recommend some frameworks for acceptance testing of Spring MVC application? Something like
Given a testng class that uses spring's test utility annotation ContextConfiguration to create beans,
I have multiple spring config files. Few are for testing. Throughout the code base
I have a Spring test that uses: @RunWith(SpringJUnit4ClassRunner.class) Unlike the older way of testing,
I'm trying to install Spring.Testing.NUnit with NuGet, and it's forcing me to update a
I'm using DBUnit for testing DAOs implemented with Hibernate and Spring. I put a
Is there a better way of testing if a string can be converted to
public class testing { testing t=new testing(); public static void main(String args[]){ testing t1=new
How can I display HTML text in textview? For example, string <h1>Krupal testing <span

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.