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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:58:34+00:00 2026-05-31T02:58:34+00:00

Can you run a test for a single method only, not a whole class?

  • 0

Can you run a test for a single method only, not a whole class? Ideally from the command line.

e.g. for a class:

public class TestClass extends Unittest {
  @Test
  public void test1_shouldbeRun() {

  }

  @Test
  public void test2_shouldNotBeRun() {

  } 
}

I only want to run the method “test1_shouldBeRun”.

  • 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-31T02:58:36+00:00Added an answer on May 31, 2026 at 2:58 am

    I do not think if that is natively supported by JUnit. However, you have some alternatives:

    1. Put the required tests in different classes so you can run them separately
    2. Maybe using the @Ignore annotation helps you.
    3. If you’re using some IDE, it may support this approach. For instance in Eclipse, unfold the test class in the Package Explorer, select the method you want to run, and click Run As -> JUnit test.
    4. Here’s a quite extensive tutorial on how to create a custom TestSuit and an Ant task that can make this for you.
    5. UPDATE In this thread the guys say that “The old junit.textui.TestRunner utility provides a way to run a single method on the command-line, via the runSingleMethod(), but it doesn’t support JUnit4 annotated test classes.“
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to run single test class from command line using Maven and TestNG
How can you run AsUnit test runner from Ant? I'm on the Mac OS
I can run a single selenium test in play's browser UI, however, is it
I'm trying to implement single instance application using mutex. the application can run only
With selenium can one run a test which check all images on a current
I am trying to test a proof of concept that I can run a
How can I run a certain cleanup task after my Test target runs, regardless
I run at path/test rm -r * The tutorial says that I can undo
I can run this command in SqlManager to detach the db ALTER DATABASE mydb
I can run RENAME TABLE student TO student_new ; The command is same 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.