Solved

JUnit Eclipse

Posted on 2008-10-14
8
289 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 100 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
 

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 400 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
network + 7 73
Printing to a specific printer tray (HP 806dn printer) 3 63
wordlen challenge 3 47
Java and GPO 11 47
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 learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

706 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now