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

The Archive Base Latest Questions

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

I have many Spring Test classes (defined using @RunWith(SpringJUnit4ClassRunner) ) that I want to

  • 0

I have many Spring Test classes (defined using @RunWith(SpringJUnit4ClassRunner)) that I want to group in test suites so that I load new configurations once for every suite instead of for every test class.

Right now I have a TestExecutionListener listener to every Spring test that will reload the configurations, but I want to save that since many tests share the same configurations.

Sadly, niether Spring supports listening to JUnit TestSuites nor JUnit supports the listener concept for TestSuites.

  • 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-04T13:24:13+00:00Added an answer on June 4, 2026 at 1:24 pm

    If you wish to perform actions before/after a junit test suite, you can use @BeforeClass and @AfterClass, or even @ClassRule. You can do your setup in there for the entire suite. Using the following example:

    @RunWith(Suite.class)
    @SuiteClasses({ ExpectedFailureTest.class, RetryTest.class })
    public class BeforeClassSuite {
      @BeforeClass
      public static void beforeClass() {
        System.out.println("beforeClass");
      }
    
      @AfterClass
      public static void afterClass() {
        System.out.println("afterClass");
      }
    
      @ClassRule
      public static ExternalResource resource = new ExternalResource() {
        @Override
        protected void before() throws Throwable {
          System.out.println("before");
        };
    
        @Override
        protected void after() {
          System.out.println("after");
        };
      };
    }
    

    This produces as output:

    before
    beforeClass
    ... output from tests
    afterClass
    after
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many cookie-cutter spring beans and don't want to explicitly define each one
I have a challenge that I am trying to solve using classes. I am
I have made a simple, test program to experiment using classes. It creates a
I have a (C++) system that has many classes that have variable storage (memory)
We have many Spring web applications to make on a WebLogic server and are
I have many items inside a list control. I want each item to have
The basic idea is that I have a family of classes that all do
Say I have a unit test that wants to compare two complex for objects
I have a problem with one-to-many relationships. I have the following domain classes: public
I have many different 3 axis sensors I am writing test code for. In

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.