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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:54:33+00:00 2026-06-12T07:54:33+00:00

In Junit, I know there is a @beforeclass , @before annotation, do we have

  • 0

In Junit, I know there is a @beforeclass , @before annotation, do we have a annotation or design,
allow us to write a method to run ONLY once before the whole testing process?

we have a script, which setup some database data (config, static, lookup table etc…..) for the test, but its too expensive to run before each individual test, we would like it to set it, only once before start running any test.

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-12T07:54:35+00:00Added an answer on June 12, 2026 at 7:54 am

    Since you tagged your question with maven, I’ll go this way: you could use the pre-integration-test phase to run this one-time expensive script (symmetrically, you clean up in post-integration-test).

    You could use exec-maven-plugin for this:

    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>...</version>
      <executions>
        <execution>
          <id>some-execution</id>
          <phase>pre-integration-test</phase>
          <goals>
            <goal>exec</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <executable><!-- runnable command or file name here --></executable>
      </configuration>
    </plugin> 
    

    JUnit does not have this kind of annotation, because it does not make any assumption about the environment: its goal is to test one class at a time in an isolated manner.

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

Sidebar

Related Questions

What are the technologies out there? (I only know of JUnit) What is the
I'm need to use JUnit 3, I know in JUnit 4 there is a
I'm learning JUnit, I know that assertEquals() invokes the equals() method to compare objects...
I would like to know if there is a way to execute some method
Is there a way to know in a JUnit 4 test Class, if the
I have Java project built with Maven2. There is used JUnit framework for testing
I know that one can define an 'expected' exception in JUnit, doing: @Test(expect=MyException.class) public
I am new to junit testing and I have the following test - public
I'd like to know if there are some unit testing frameworks which are capable
I know that this topic was discussed there a lot of times, but I've

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.