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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:10:50+00:00 2026-06-16T10:10:50+00:00

I have a question when I was using JUnit 4. There is one thing

  • 0

I have a question when I was using JUnit 4. There is one thing really confused me.
Why does the following has no main function, but it can be executed and give the testing result back? It does not even extend a class. So confused…. The code are as followed:

import org.junit.runner.RunWith;    
import org.junit.runners.Suite;    
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)    
@SuiteClasses({ ATest.class,BTest.class })    
public class AllTests {

}
  • 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-16T10:10:51+00:00Added an answer on June 16, 2026 at 10:10 am

    The main method (not function) is implemented in the runner class. The runner class is invoked by the IDE or the build tool, then the runner loads the Test classes and executes all the methods that are marked (ie. by @Test annotation).

    The lifecycle of a test is a bit more complex than a main function.
    You can have a preparation (@BeforeClass and @Before annotated methods) before to execute each @Test, then a clean up (@After and @AfterClass annotated methods).

    This framework gives you more flexibility than just having a single main method. Also annotated tests can be ran individually: you may have a huge test suite, but you may want to run just a failing test repeatedly while correcting a bug; this cannot be done with a main method (unless you have a main method for every test).

    There are several advantages in using a framework like JUnit over plain Java classes with a main, as you can see.

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

Sidebar

Related Questions

I have a question regarding using Semaphores HANDLE WINAPI CreateSemaphore(...); Is there anyway I
i have a (perhaps stupid) question: im using 2 threads, one is writing floats
I have a basic question: When using JUnit, in your test suite (the class
I have some question about using queues and threads. I already made researches, but
I have one question regarding using JQuery UI tab control in the asp.net mvc
I start using Junit, and I have a very basic question. I want to
I have organised my junit tests using one inner class per method as described:
I have a question about using HTTPS in a JBossAS7 web application (a universal
i have a question about using GalleryView. At first, i set five default images
I have a question about using subqueries in an Update statement. My example: UPDATE

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.