File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Ant for Junit Test cases using annotation.

 
Meghana Phatak
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Meghana Phatak
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ant 1.6.5 doesn't provide native support for JUnit 4, see this article for some workarounds.
 
Meghana Phatak
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic