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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:33:24+00:00 2026-05-30T03:33:24+00:00

Is it possible to run an external command before running tests in a given

  • 0

Is it possible to run an external command before running tests in a given JUnit file? I run my tests using the Eclipse’s Run command. Using JUnit 4.

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-05-30T03:33:26+00:00Added an answer on May 30, 2026 at 3:33 am

    Very vague question. Specifically, you didn’t mention how you are running your JUnit tests. Also you mentioned ‘file’, and a file can contain several JUnit tests. Do you want to run the external command before each of those tests, or before any of them are executed?

    But more on topic:

    If you are using JUnit 4 or greater then you can tag a method with the @Before annotation and the method will be executed before each of your tagged @Test methods. Alternatively, tagging a static void method with @BeforeClass will cause it to be run before any of the @Test methods in the class are run.

    public class MyTestClass {
    
        @BeforeClass
        public static void calledBeforeAnyTestIsRun() {
            // Do something
        }
    
        @Before
        public void calledBeforeEachTest() {
           // Do something
        }
    
        @Test
        public void testAccountCRUD() throws Exception {
        }
    }
    

    If you are using a version of JUnit earlier than 4, then you can override the setUp() and setUpBeforeClass() methods as replacements for @Before and @BeforeClass.

    public class MyTestClass extends TestCase {
    
        public static void setUpBeforeClass() {
            // Do something
        }
    
        public void setUp() {
           // Do something
        }
    
        public void testAccountCRUD() throws Exception {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to run an external command and store its output in a
Possible Duplicate: C#: Run external console program as hidden I am using a Windows
Is it possible to run an external process from Perl, capture its stderr, stdout
Using only MySQL , I'm seeing if it's possible run an insert statement ONLY
Is it possible to run a batch file as a menu item in studio
Is it possible to run an UPDATE command on mysql 5.0 with a sub
I would like to run all my django tests using mercurial's precommit hook. Whenever
In xcode 3, using a bash script, I could run xcode from the command
I am using an external dll in my project. When i try to run
I wish to use an external Text/CSV file to read data and run an

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.