Invoke a JUnit test case

Posted on 2011-02-16
Last Modified: 2012-08-14
I am using Junit 4.


I have many JUnit test cases. In GUI, of course, I know how to run it. And see the result. The trace information is written into a log file. Then I collect data in the excel.

Now I want above process totally automated. I want to write a main function, in this main function, I invoke selected test case, and trace information is recorded into log and I collect data and write to excel. I know how to collect data from log and then write to excel. But I am wondering how to invoke selected test cases in my main class. Does JUnit provide some API so that I could run test case easily instead of using reflection.


Question by:JianJunShen
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 92

Expert Comment

ID: 34913834
LVL 92

Expert Comment

ID: 34913839
you can also use org.junit.runner.JUnitCore

Author Comment

ID: 34938566
Sorry, What about I am using Maven. Are there some Maven plugin allowing me just test one, or selected test cases?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 92

Assisted Solution

objects earned 500 total points
ID: 34938808

Author Comment

ID: 35059904
What about I just want to test one java file. For example, In which, there are a couple of test I want and I only want to run this java file for one particular purpose.
LVL 92

Accepted Solution

objects earned 500 total points
ID: 35061740
then you would just run it with org.junit.runner.JUnitCore

Author Comment

ID: 35112413
I need more time to check...
LVL 60

Expert Comment

by:Kevin Cross
ID: 37514372
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
iterator/ListIterator approach 17 68
Java: The Public Class Main 4 66
dao vs facade design patterns 2 76
Read CLOB data from Oracle using JAVA 3 44
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question