my dog learned polymorphism*
The moose likes IDEs, Version Control and other tools and the fly likes Setup - JUnit and Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Setup - JUnit and Eclipse" Watch "Setup - JUnit and Eclipse" New topic
Author

Setup - JUnit and Eclipse

Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
I have JUnit set up with Eclipse. But my test won't run.


It's pretty darn simple. How come it won't work? I'm using JUnit 4 included with Eclipse.

It says <terminated> above the console.


comp.lang.javascript FAQ: http://jibbering.com/faq/
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
why do you call it a test?


java amateur
Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
I want to test that I can test.

But I cannot
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Garrett,
What version of Eclipse are you using?

I'm moving this to the IDEs forum, since the unit test itself is fine.


[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
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15957
    
  19

I've not seen JUnit done with annotations. The traditional convention is that you make a class that parallels the class name to be tested and name it "classnameTest", using the original class name as the value of "classname" and making it a subclass of a JUnit base class. Then Eclipse can run it via a right-click menu option.


Customer surveys are for companies who didn't pay proper attention to begin with.
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
pardon my ignorance, pls
@ Jeanne Boyarsky
why do you consider that code an unit test?
because of the @test anotation??
ty
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Miguel,
JUnit 4 supports annotations instead of having to extend TestCase. I don't know if the IDEs are up to it though.
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
ty, Jeanne
i was shocked when i (re)visited junit site, but then i understood: anotations means junit4, while all i knew about was plain old 3 version
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Garrett, in my Eclipse 3.2 that test class works just fine (as long as you add the JUnit 4 .jar file to the project's classpath).

How are you trying to run it?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
Don't get me started about those stupid light bulbs.
 
subject: Setup - JUnit and Eclipse
 
Similar Threads
how to write and run junit test cases in eclipse?
eclipse and and junit
junit examples
jmock class loader can not find the interface org.jmock.internal.CaptureControl
Parser confign excn - When running JUNIT in Spring application