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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:37:04+00:00 2026-06-09T00:37:04+00:00

Using JUnit4, what I want to do is to be able to test a

  • 0

Using JUnit4, what I want to do is to be able to test a group of different java projects that all do the same thing, but instead of have to write out a test case to test each project i was wondering is it possible to write a single test that can be run on multiple classes?

If this is not possible using JUnit4, is it possible to do this any other way?

I know this isnt right but this is just to give a brief idea of what I am on about:

@Test
public void test(Class insertClassNameHere, Method nameOfMethod){
    Class insertClassNameHere = new Class();
    assertEquals(insertClassNameHere.nameOfMethod(),1);
}
  • 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-09T00:37:08+00:00Added an answer on June 9, 2026 at 12:37 am

    You can using JUnit’s @Parameterized.

    @RunWith(Parameterized.class)
    public class BehaviorTest {
        @Parameters
        public static Collection<Object[]> classesAndMethods() {
            List<Object[]> list = new ArrayList<Object[]>();
            list.add(new Object[]{ Foo.class, Foo.class.getMethod("foo") });
            return list;
        }
    
        private Class clazz;
        private Method method;
    
        public BehaviorTest(Class clazz, Method method) {
             this.clazz = clazz;
             this.method = method;
        }
    
        @Test
        public void testBehavior() {
            // Do stuff
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Selenium RC and created all scripts in java (Using Junit test case)
I want to test the result of a java method that returns a Set
I am very new using JUnit. I want to test some classes that implements
I want to test my class MyTypeDAO implemented with Hibernate 4.1 using JUnit 4.9.
I read in a few posts that using JUnit to test concurrency is not
I'm developing Android application using third party libraries (Twitter4j). I want to be able
I'm writing a JUnit test using JUnitPerf. Here, I want to generate some entries
I'm writing a JUnit test and also using Mockito, and I want to call
I'm working on a project at the moment that we're using junit to test,
We have a URL object in one of our Java classes that we want

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.