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

x
?
Solved

JUnit Eclipse

Posted on 2008-10-14
8
Medium Priority
?
299 Views
Last Modified: 2013-12-15
Hello,
I have two packages in one Project.  In the first package I have a java file that contains "main," and in the other java file I have the code I am working with.  I am running them as "Java Application," but I wish to run them as a JUnit.  If I would have started the java files off as JUnits from the beginning I would not have this problem now.  So I need to convert the java files I now have to run as JUnit.  How shall I do this.  I have tried setting the Debug Configuration, but I run into one problem or the other.
0
Comment
Question by:chima
  • 4
  • 3
8 Comments
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 22718017
In eclipse, you can select a folder and right click->New->Junit Testcase
More on how to write testcase http://www.thekirschners.com/articles/how-to-write-test-cases.html
0
 
LVL 5

Assisted Solution

by:muktajindal
muktajindal earned 400 total points
ID: 22718025
Are you extending TestCase class ?
0
 

Author Comment

by:chima
ID: 22720366
Ajay-Singh, I am looking more for the Eclipse setting of the "Run Configuration" or the "Debug Configurtation.  I think it is more the Debug Configuration."

muktajindal, If I had started with JUnit I would not have this problem.  Of course I could set it up as JUnit and copy the code over, but I wanted to learn how to get from a Java run as "Java Application" to "Run as JUnit."  I have seen it done once, but when I go to do it, I run into a couple of different problems.  One says; No test for JUnit 4 or 3.  And the other just does not let me select the java file I want.
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!

 

Author Comment

by:chima
ID: 22721380
Now I see what you mean by "extending Testcase" and yes this was the problem.  Now I have a related problem, which I found a web site explaining "multiple inheritance."  I see that it is not straight forward, so I wanted to ask; I have  public class XmlTest extends XMLTestCase.  How would I add another extention, i.e., public class XmlTest extends Fixture, XMLTestCase
Extending or adding Fixture
0
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 1600 total points
ID: 22722532
> How would I add another extention

You can't do that. Java doesn't support multiple inheritance.
0
 

Author Comment

by:chima
ID: 22723030
Ajay-Singh, not directly, but it is possible, right?  http://pclc.pace.edu/~bergin/patterns/multipleinheritance.html explains how, or at least I think it does.  I have not had time to read through it.
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 22728224
It is possible for interfaces (which are not concrete classes), not for concrete classes. I was referring to
concrete classes, where there is no multiple inheritance.
0
 

Author Closing Comment

by:chima
ID: 31506147
thanks, more to come
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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…
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:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
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