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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:36:29+00:00 2026-06-09T22:36:29+00:00

I am trying to use JUnitCore.runClasses() and I can get it running using the

  • 0

I am trying to use JUnitCore.runClasses() and I can get it running using the following code

JUnitCore.runClasses(testClass.class);

But i was curious, as runClasses() can take any number of parameters, is it possible to use code similar to the following?

Class c = testClass.class;
JUnitCore.runClasses(c);

Or

List<Class> c = new ArrayList<>{test1.class, test2.class, test3.class};
JUnitCore.runClasses(c);

I am asking this as if you try to pass a java.io.File type to JUnitCore.runClasses() you get the following error

no suitable method found for runClasses(java.io.File)
method org.junit.runner.JUnitCore.runClasses(java.lang.Class<?>...) is not applicable
  (argument type java.io.File does not conform to vararg element type java.lang.Class<?>)
method org.junit.runner.JUnitCore.runClasses(org.junit.runner.Computer,java.lang.Class<?>...) is not applicable
  (actual argument java.io.File cannot be converted to org.junit.runner.Computer by method invocation conversion)
  • 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-09T22:36:30+00:00Added an answer on June 9, 2026 at 10:36 pm

    I assume you are trying to do the following:

    You have a file containing a java class which you want to run using JUnitCore.

    To acomplish this you will have to:

    1. Load the class, this can be done by using a custom class loader. A better approach would be to just include the class into your application
    2. Now you can invoke JUnitCore.runClasses(loadedClass);

    Code sample:

    File file = new File("path to your file");
    File dir = file.getParentFile();
    URL url = new URL("file://" + dir.getAbsolutePath());
    URLClassLoader classLoader = new URLClassLoader(new URL[]{url});
    Class<?> clazz = classLoader.findClass("ClassName");
    JUnitCore.runClasses(clazz);
    

    The example will only work if the class does not have a package. You can write an own class loader to control the class loading process. See the javadoc for URLClassLoader to learn how this class loader works. For writing a custom class loader you could consult this.

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

Sidebar

Related Questions

trying to use the preferred on method call but the code is not working
I am trying use filehelpers class builder but I am kinda confused on what
I was trying use svn to find a checkin using svn log, but it
Im trying use a Java annotation in a Groovy class but have trouble to
I am trying use TinyMCE to get code syntax to be displayed in the
I'm trying use this code to get image resolution from file bool GetImageSizeEx(const char
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
trying to use hibernate with my web app and getting following exception: Initial SessionFactory
I am trying use MySql and Entity Framework, using Connector/Net 6.1 with this as
Anyone know how to create a cvCreateStructuringElementEx using a image? I'm trying use opencv.cv.cvCreateStructuringElementEx()

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.