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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:41:25+00:00 2026-05-14T00:41:25+00:00

From Eclipse I can easily run all the JUnit tests in my application. I

  • 0

From Eclipse I can easily run all the JUnit tests in my application.

I would like to be able to run the tests on target systems from the application jar, without Eclipse (or Ant or Maven or any other development tool).

I can see how to run a specific test or suite from the command line.

I could manually create a suite listing all the tests in my application, but that seems error prone – I’m sure at some point I’ll create a test and forget to add it to the suite.

The Eclipse JUnit plugin has a wizard to create a test suite, but for some reason it doesn’t “see” my test classes. It may be looking for JUnit 3 tests, not JUnit 4 annotated tests.

I could write a tool that would automatically create the suite by scanning the source files.

Or I could write code so the application would scan it’s own jar file for tests (either by naming convention or by looking for the @Test annotation).

It seems like there should be an easier way. What am I missing?

  • 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-14T00:41:25+00:00Added an answer on May 14, 2026 at 12:41 am

    I ran into a minor problem with my last solution. If I ran “all tests” from Eclipse they ran twice because they ran the individual tests AND the suite. I could have worked around that, but then I realized there was a simpler solution:

    package suneido;
    
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.Enumeration;
    import java.util.jar.JarEntry;
    import java.util.jar.JarFile;
    
    public class RunAllTests {
    
        public static void run(String jarfile) {
            String[] tests = findTests(jarfile);
            org.junit.runner.JUnitCore.main(tests);
        }
    
        private static String[] findTests(String jarfile) {
            ArrayList<String> tests = new ArrayList<String>();
            try {
                JarFile jf = new JarFile(jarfile);
                for (Enumeration<JarEntry> e = jf.entries(); e.hasMoreElements();) {
                    String name = e.nextElement().getName();
                    if (name.startsWith("suneido/") && name.endsWith("Test.class")
                            && !name.contains("$"))
                        tests.add(name.replaceAll("/", ".")
                                .substring(0, name.length() - 6));
                }
                jf.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return tests.toArray(new String[0]);
        }
    
        public static void main(String[] args) {
            run("jsuneido.jar");
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a problem debugging an Eclipse Application from Eclipse. When I launch the
I'm developing a SWT/JFace application using the libraries from Eclipse 3.4.1. I encounter the
I'm coming from Eclipse, working in Visual Studio 2008 Express and just want to
I am upgrading my environment from eclipse 3.3.1 and java 1.4 to eclipse 3.4.1
I've committed changes in numerous files to a SVN repository from Eclipse. I then
The output we get when printing C++ sources from Eclipse is rather ugly. Is
Is it possible to use a Spring container for DI from inside Eclipse plugins?
I reference another eclipse project from the current project I am working on. Everything
I recently upgraded to Eclipse Ganymede from Europa and now I'm finding that when
I have checked in a huge Eclipse project from my desktop computer to the

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.