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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:45:06+00:00 2026-06-10T05:45:06+00:00

I am currently developing a system that will, hopefully, be used to compare the

  • 0

I am currently developing a system that will, hopefully, be used to compare the results of two individual, but identically-named classes. By comparing the two classes, I hope to be able to determine if the outputs from the first classes methods are the same as the outputs from the second classes methods, given the same input parameters.

How would I go about running the same test class on two independent classes, dynamically?

Psudocode example:

If I have a simple test class…

class TestClass{
   public int TestMethod(int num){
   int num2;
   TestedClass t = new TestedClass();
   num2 = t.add(num);
}

and two identical classes that need to be tested…

class TestedClass{
    public int add(int num){
    num = num + 2;
    return num;
}

and

class TestedClass{
    public int add(int num){
    num = num + 4;
    return num;
}

How would I go about running the TestClass with respect to the two different TestedClass, and then saving the result of the tests in some form of collection.

As you can see, the two TestedClass’s are identically named and the return types are identical, only the functionality differs slightly. I also do not have access to change the TestedClass’s, however I can control where they are located within the program, package etc.

Thanks in advance.

EDIT:

Appeared to have very cleverly missed out a very important piece of information:

I also do not have access to edit the TestClass, although, as above, I will know the class/method names and have control over where they are located. The idea is to build something that can dynamically test a class given a copy of the input and correct output (the TestClass and the other TestedClass).

Apologies for the confusion.

EDIT 2:
I have access to the tests, ie. I can run them, I just cannot edit them, for example as a few answers suggested.

  • 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-10T05:45:08+00:00Added an answer on June 10, 2026 at 5:45 am
    foo.bar.TestedClass   c1 = new foo.bar.TestedClass();
    baz.plugh.TestedClass c2 = new baz.plugh.TestedClass();
    assertEquals(c1.add(42), c2.add(42));
    

    Edit

    You don’t need to run the two tests in the same JVM, you can just call the methods, save the output, and compare using any variety of techniques. Or you could scan for classes the same way old JUnit did it and instantiate via Class.forName("...").newInstance() and run methods via reflection.

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

Sidebar

Related Questions

I am currently developing a database system for a school that will work with
I'm a java developer, currently starting developing a hospital management system that will server
I am currently developing an application , that will be published on appstore. I
I am currently developing a system that has need for a session time out
I am developing a system that will provide many services, say, S1 , S2
Currently, I'm developing a system which will extract some files from an SFX archive
I'm currently developing an android app that will regularly stop to watch streamed video.
I'm currently developing an app that will allow the user to choose an app
Im currently developing a system where the user will end up having large arrays(
I'm currently developing a Blog project using Post model, which will be used by

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.