wood burning stoves 2.0*
The moose likes Testing and the fly likes How to use JUnit with Eclipse ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to use JUnit with Eclipse ?" Watch "How to use JUnit with Eclipse ?" New topic
Author

How to use JUnit with Eclipse ?

somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Hi all,

I'm new guy in JUtit testing,
Now, i'm study in JUnit with Eclipse ....

How to use JUnit with Eclipse ?

I'm studying tutorial at http://www.onjava.com/pub/a/onjava/2004/02/04/juie.html

but this tutorial is very short tutorial , so Do you have more JUnit + Eclipse Tutorial ??


SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by somkiat puisungnoen:
How to use JUnit with Eclipse ?


What are your doubts?

Generally, there is not much special about using JUnit inside Eclipse. You write your JUnit tests as usual, optionally using Eclipses wizards to do so, and run them using Eclipses inbuild testrunner.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Laurent Barbier
Greenhorn

Joined: Jun 08, 2004
Posts: 7
I've found this tutorial about TDD (Test Driven Development) using Junit with Eclipse :

http://www.ammai.com/downloads/TDDEclipse_viewlet_swf.html

I think it might help
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Originally posted by Laurent Barbier:
I've found this tutorial about TDD (Test Driven Development) using Junit with Eclipse :

http://www.ammai.com/downloads/TDDEclipse_viewlet_swf.html

I think it might help


That good tutorial ....


Thank a lot ...

I'm can use JUnit to test my first application , so it's work.
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
What about this tutorial? It's from 3plus4software and is longer than the tutorial from OnJava... Traffic light Simulatrion Model is there as an example... Hope this helps...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Originally posted by Ilja Preuss:


What are your doubts?

Generally, there is not much special about using JUnit inside Eclipse. You write your JUnit tests as usual, optionally using Eclipses wizards to do so, and run them using Eclipses inbuild testrunner.



I don't know how to use junit wizard in Eclipse . And thank you for solution to use JUnit in Eclipse.



And I have some question:

When i should use JUnit to testing my application ??



Because i never use JUnit for testing application.
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by somkiat puisungnoen:
And I have some question:

When i should use JUnit to testing my application ??


Because i never use JUnit for testing application.


If I am not wrong, I guess you mean "Why use JUnit", instead of "When to use JUnit" in your question...

If your question means to the word "why", these reasons would be enough to know why we need to use JUnit for testing applications... As I told in the previous thread, I was told by one of your management level employees at your previous company "Mustang" that I should use JUnit and ANT in application development all the time... That guy's name is Roy <Sthing>. I don't remember his lastname...

Before that, I had been neglecting the importance of JUnit and ANT... But I'm on them since then.... Still on the learning track like you...
[ August 10, 2004: Message edited by: Ko Ko Naing ]
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Thank you very much ....
Tony Yan
Ranch Hand

Joined: Apr 10, 2002
Posts: 170
Why not Ant?


Tony Yan<br /> <br />IBM Certified Developer XML and Related Technology<br />Sun Certified Web Component Developer For J2EE Platform<br />Sun Certified Programmer For Java 2 Platform
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Tony Yan:
Why not Ant?

If your "project" is an experiment you're doing alone all within your IDE, it might not be necessary to use Ant since you can do all your common tasks within your state-of-the-art IDE without having to consider build portability etc.

In general, Ant is pretty much a given these days. It's probably about 4 years since I last encountered a Java project using something other than Ant to build their stuff.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Tony Yan:
Why not Ant?


"Why not Ant" what?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

Somkiat,
The junit wizard assumes you have a class to test (the class doesn't need to have any methods in it, it just needs to exist.) The test case wizard lets you select what folder you want to put the test class in and if you want a custom superclass. You can choose to have it create setUp()/tearDown() methods and the type of test runner. (The test runner choice isn't as useful as you will probably want to use the Eclipse runner.) If your class has any methods, you can have the wizard create test method stubs for you.

There is also a wizard that creates a test suite (to run some subset of your test classes.)


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Jeanne Boyarsky:
The junit wizard assumes you have a class to test (the class doesn't need to have any methods in it, it just needs to exist.)


It doesn't even need to exist - it's optional! So you can easily use it in a test-first style.


There is also a wizard that creates a test suite (to run some subset of your test classes.)


And don't forget the "recreate test suite" command from the context menu on a test suite. Very usefull!
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Originally posted by Jeanne Boyarsky:
Somkiat,
The junit wizard assumes you have a class to test (the class doesn't need to have any methods in it, it just needs to exist.) The test case wizard lets you select what folder you want to put the test class in and if you want a custom superclass. You can choose to have it create setUp()/tearDown() methods and the type of test runner. (The test runner choice isn't as useful as you will probably want to use the Eclipse runner.) If your class has any methods, you can have the wizard create test method stubs for you.

There is also a wizard that creates a test suite (to run some subset of your test classes.)



Thank you very much for more detail.

I'm done follow you , it's work...
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

It doesn't even need to exist - it's optional! So you can easily use it in a test-first style.

You're right. I meant that the class needs to exist if you want it to generate test stubs. But I certainly didn't type that. Sorry!

And don't forget the "recreate test suite" command from the context menu on a test suite. Very usefull!

That one I didn't know about. I use a reflection based test suite, so I'm not that familiar with what Eclipse gives you for test suites.
somkiat puisungnoen
Ranch Hand

Joined: Jul 04, 2003
Posts: 1312
Originally posted by Tony Yan:
Why not Ant?


I not sure I understand this question.

I think, you mean (ANT) to build application (Compile/Run/Deploy) but JUnit is some library/class/interface for testing application , so you can use ant to run JUnit .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use JUnit with Eclipse ?
 
Similar Threads
Passing initialization params to Action class
JUnit and Eclipse
Help Required
JUnit for SCJD
balancer webapp