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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:37:32+00:00 2026-06-13T09:37:32+00:00

I know that to run junit from command line you can do this: java

  • 0

I know that to run junit from command line you can do this:

java org.junit.runner.JUnitCore TestClass1 […other test classes…]

However, I want to run many tests together and manually typing “TestClass1 TestClass2 TestClass3…” is just inefficient.

Current I organize all test classes in a directory (which has sub-directories indicating the packages). Is there any way that I can run junit from command line and let it execute these test classes all at once?

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-13T09:37:33+00:00Added an answer on June 13, 2026 at 9:37 am

    I found that I can write an Ant buildfile to achieve this. Here is the sample build.xml:

    <target name="test" description="Execute unit tests">
        <junit printsummary="true" failureproperty="junit.failure">
            <classpath refid="test.classpath"/>
            <!-- If test.entry is defined, run a single test, otherwise run all valid tests -->
            <test name="${test.entry}" todir="${test.reports}" if="test.entry"/>
            <batchtest todir="tmp/rawtestoutput" unless="test.entry">
                <fileset dir="${test.home}">
                    <include name="**/*Test.java"/>
                    <exclude name="**/*AbstractTest.java"/>
                </fileset>
                <formatter type="xml"/>
            </batchtest>
        <fail if="junit.failure" message="There were test failures."/>
    </target>
    

    With this build file, if you want to execute a single test, run:

    ant -Dtest.entry=YourTestName
    

    If you want to execute multiple tests in batch, specify the corresponding tests under the <batchtest>...</batchtest>
    as shown in the above example.

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

Sidebar

Related Questions

I know that I can run an external Javascript file from within HTML with
I am attempting to run a JUnit Test from a Java Class with: JUnitCore
I know that it's bad to run any kind of GUI widget from within
I know that cd is a shell built-in ,and I can run it by
Do you know any tools that can run through the code and find defects
I know that TextBlock can present a FlowDocument , for example: <TextBlock Name=txtFont> <Run
I know that we can make application using Adobe air that will run on
We use function tests in a java project that we run with junit and
I'm having problems with a java.lang.NoClassDefFoundError when trying to run my JUnit tests from
Basically, I'm writing a Java Command-line application which accept parameter from user by readLine.

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.