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

  • Home
  • SEARCH
  • 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 6947285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:40:28+00:00 2026-05-27T13:40:28+00:00

I want to execute a junit testcase inside another java program.. Let’s say class

  • 0

I want to execute a junit testcase inside another java program.. Let’s say

class XYZ extends TestCase{
    public void test1(){}
    public void test2(){}
    public void test3(){}
}

Like the way I run this unit test on eclipse, I want to be able to execute this at run time..I need to know the number of tests passed and failed.. I tried the typical java way of doing this by creating an object of this testcase class and invoking each function one by one but somehow I felt it is ineffective to do so.. Also, it does execute the tests but doesn’t tell me anything about the statistics about tests passed and failed..

So how can I execute all this tests at run time within another java program, mimicking what eclipse does?

  • 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-27T13:40:28+00:00Added an answer on May 27, 2026 at 1:40 pm

    You can use the JunitCore class to execute tests programmatically. This will return a Result which you will have to evaluate for yourself.

    Once you have tests, you’ll want to run them. JUnit provides tools to
    define the suite to be run and to display its results. To run tests
    and see the results on the console, run this from a Java program:

    org.junit.runner.JUnitCore.runClasses(TestClass1.class, ...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 2 files: xxxxxTest.java [ refer this ] public class xxxxxTest extends TestCase
I want to execute a batch file from a java program. I am using
public class CalculatorTest extends TestCase { Calculator calc = new Calculator(); public void testAdd()
I want to execute a external .exe program from within java. The .exe is
I want to execute another program within C code. For example, I want to
I want to execute a random .py file, say foo.py on the myproject/myapp folder
I want to execute the slot of different class. When i execute this code
I want to execute a SQL query inside PL/SQL and populate the results into
I want to execute this sql script inside my seed.rb LOAD DATA LOCAL INFILE
I want to execute a php-script from php that will use different constants and

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.