This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes ant junit tests expected exception always fail 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 » Ant, Maven and Other Build Tools
Bookmark "ant junit tests expected exception always fail" Watch "ant junit tests expected exception always fail" New topic
Author

ant junit tests expected exception always fail

Robert Panivino
Greenhorn

Joined: Nov 27, 2013
Posts: 5

Having the above type of test, the ant task confirms that the correct exception is indeed thrown, but it registers the test as failed, because it probably isn't smart enough to parse the expected property on the @Test annotation.

Does anyone have any ideas how to not change the tests and fix this annoying issue?
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

Robert,
Welcome to CodeRanch!

Does your test class extend TestCase by any chance? If so, it is running the test as a JUnit 3.8 test which would ignore the annotation completely.


[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
Robert Panivino
Greenhorn

Joined: Nov 27, 2013
Posts: 5
Jeanne Boyarsky wrote:Robert,
Welcome to CodeRanch!

Does your test class extend TestCase by any chance? If so, it is running the test as a JUnit 3.8 test which would ignore the annotation completely.


Thank you, it's nice to be here.

I forgot to update my status. I had a few errors - and my Test class doesn't extend anything related to junit tests, only the methods are adnotated.
Firstly,
<jvmarg value="-Djboss.server.home.dir=${jboss.server.home.dir}" />
^ that does nothing when fork is set to false. Secondly, it seems that for some reason I had two ant libraries, one in eclipse and one in jboss. If I ran the corrected ant file in the command line, it would work properly, so I had to solve the double library issue.
And finally, in windows each command is limited to ~8k characters, thus a complex classpath will screw you, so I had to switch to linux.

Now I've got to do the jenkins integration, hopefully it won't be as annoying.

Thank you and have a nice day.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30138
    
150

Thanks for posting the solution.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ant junit tests expected exception always fail
 
Similar Threads
problem with ant, junit, NetBeans, Java, or me
Running JUnit 4 with Ant 1.6.5
ANT JUnit Problem
Running JUnit 4 with Ant 1.6.5
Running JUnit 4 with Ant 1.6.5