File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant for Junit Test cases using annotation. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Ant for Junit Test cases using annotation." Watch "Ant for Junit Test cases using annotation." New topic
Author

Ant for Junit Test cases using annotation.

Meghana Phatak
Greenhorn

Joined: Apr 17, 2009
Posts: 4
Hello Everyone,

I am trying to run my Test case class using junit task. The class runs very well from command line or eclipse.
However I get an error while I try to run using junit task.
The error is as follows :
TestClass has no public constructor TestCase(String name) or TestCase()
junit.framework.AssertionFailedError: TestClass has no public constructor TestCase(String name) or TestCase().

MyClass uses annotation @Test insteadi of inheriting from TestCase.

Can anyone help me?


Regards,
Meghana
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Hi Meghana and welcome to Javaranch!

It sounds like you've got a JUnit version clash, are you setting the JUnit task to run as JUnit 4?


Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
Meghana Phatak
Greenhorn

Joined: Apr 17, 2009
Posts: 4
Hello Martijn,

I did not explicitly set the task to run as Junit 4. However I do have junit 4 jar kept in the classpath of ant. Do we have to modify any settings to run junit 4 tasks?

Regards,
Meghana
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

Ant 1.6.5 doesn't provide native support for JUnit 4, see this article for some workarounds.
Meghana Phatak
Greenhorn

Joined: Apr 17, 2009
Posts: 4
Hey Martijn,

I upgraded my ant to 1.7 and now it is working. Thanks a lot. I really appreciate your help.


Meghana.
Martijn Verburg
author
Bartender

Joined: Jun 24, 2003
Posts: 3274
    
    5

You're welcome
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ant for Junit Test cases using annotation.
 
Similar Threads
Basic question on JUnit Test Suite
Junit error
JUnit TestCollector Error
Running batches of unit tests in a hierarchy with non-unit test tests
JUnit Test