Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Invoke a JUnit test case

Posted on 2011-02-16
9
Medium Priority
?
507 Views
Last Modified: 2012-08-14
I am using Junit 4.

Target:

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.

Problem:
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.

Juhani

 
0
Comment
Question by:JianJunShen
  • 4
  • 3
9 Comments
 
LVL 92

Expert Comment

by:objects
ID: 34913839
you can also use org.junit.runner.JUnitCore
http://junit.sourceforge.net/doc/cookbook/cookbook.htm
0
 

Author Comment

by:JianJunShen
ID: 34938566
Sorry, What about I am using Maven. Are there some Maven plugin allowing me just test one, or selected test cases?
0
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

by:objects
objects earned 2000 total points
ID: 34938808
0
 

Author Comment

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

Accepted Solution

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

Author Comment

by:JianJunShen
ID: 35112413
I need more time to check...
0
 
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.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn different types of Android Layout and some basics of an Android App.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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:
Suggested Courses

972 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