Solved

JUnit Eclipse

Posted on 2008-10-14
8
290 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

863 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

22 Experts available now in Live!

Get 1:1 Help Now