aspose 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Reply 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: 3268

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

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

You're welcome
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Ant for Junit Test cases using annotation.
 
Similar Threads
JUnit Test
Basic question on JUnit Test Suite
Junit error
JUnit TestCollector Error
Running batches of unit tests in a hierarchy with non-unit test tests