Solved

JUnit Eclipse

Posted on 2008-10-14
8
293 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
[X]
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
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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 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

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android development question 2 110
Adding multiple JVM environments to RedHat 6 7 82
Selenium findElement(By.classname  identifier 15 37
Java regex 5 22
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

759 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