wood burning stoves 2.0*
The moose likes Testing and the fly likes Why doesn't the JUnit test OUTPUT appear using the Ant build?    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 » Testing
Bookmark "Why doesn Watch "Why doesn New topic
Author

Why doesn't the JUnit test OUTPUT appear using the Ant build?

Abder-Rahman Ali
Ranch Hand

Joined: May 22, 2008
Posts: 138
Why doesn't the JUnit test OUTPUT appear using the Ant build

<target name="JUnit test">
<junit printsummary="true" showoutput="yes">
<classpath refid="test.classpath"/>
<formatter type="plain"/>
</junit>
</target>

Thanks.
Seamus Minogue
Ranch Hand

Joined: Jun 24, 2008
Posts: 41


Think you might be missing this...

From my build file
Abder-Rahman Ali
Ranch Hand

Joined: May 22, 2008
Posts: 138
Seamus Minogue wrote:

Think you might be missing this...

From my build file


Thank you very much.
Abder-Rahman Ali
Ranch Hand

Joined: May 22, 2008
Posts: 138
Why do I get this error when I run the Ant build file?

Testsuite: JUnit
Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec

Caused an ERROR
JUnit
java.lang.ClassNotFoundException: JUnit
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423)
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137)
Seamus Minogue
Ranch Hand

Joined: Jun 24, 2008
Posts: 41
looks like you need to tweak that classpath entry I gave you so that junit.jar is on it.

^^ Idiocy please ignore


Actually im sorry I am seeing things. Your test case is called JUnit!

Ok well THAT isnt on the classpath...
Abder-Rahman Ali
Ranch Hand

Joined: May 22, 2008
Posts: 138
Seamus Minogue wrote:looks like you need to tweak that classpath entry I gave you so that junit.jar is on it.


Since I'm using "Eclipse", I added JUnit to Ant, so it is working properly.

But, as for the test that you gave me, what should I change in it?

Thanks.
Seamus Minogue
Ranch Hand

Joined: Jun 24, 2008
Posts: 41
Create a property called build.tests which has a value that is the same as where your javac command compiled your test classes to and it should work
Abder-Rahman Ali
Ranch Hand

Joined: May 22, 2008
Posts: 138
Seamus Minogue wrote:Create a property called build.tests which has a value that is the same as where your javac command compiled your test classes to and it should work


This is what I get when I run it:

Testsuite‭: ‬PojoTests
Tests run‭: ‬1‭, ‬Failures‭: ‬0‭, ‬Errors‭: ‬1‭, ‬Time elapsed‭: ‬0‭ ‬sec

Caused an ERROR
PojoTests
java.lang.ClassNotFoundException‭: ‬PojoTests
at java.net.URLClassLoader$1‭.‬run(URLClassLoader.java:200‭)‬
at java.security.AccessController.doPrivileged(Native Method‭)‬
at java.net.URLClassLoader.findClass(URLClassLoader.java:188‭)‬
at java.lang.ClassLoader.loadClass(ClassLoader.java:316‭)‬
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280‭)‬
at java.lang.ClassLoader.loadClass(ClassLoader.java:251‭)‬
at java.lang.ClassLoader.loadClass(ClassLoader.java:251‭)‬
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374‭)‬
at java.lang.Class.forName0‭(‬Native Method‭)‬
at java.lang.Class.forName(Class.java:242‭)‬
at org.eclipse.ant.internal.ui.antsupport.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32‭)‬
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:423‭)‬
at org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:137‭)‬


Provided that I thin you should have a "/" at the end of the following line:

<pathelement path="${classpath}" >
Seamus Minogue
Ranch Hand

Joined: Jun 24, 2008
Posts: 41
oops... copy paste error.

I think you're right

Sorry about that
Abder-Rahman Ali
Ranch Hand

Joined: May 22, 2008
Posts: 138
Seamus Minogue wrote:oops... copy paste error.

I think you're right

Sorry about that


Thats fine. but, still is not working, don't know why.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30068
    
149

Abder-Rahman Ali wrote:Thats fine. but, still is not working, don't know why.

What does 'not working" mean? Do you get an error message?


[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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Why doesn't the JUnit test OUTPUT appear using the Ant build?
 
Similar Threads
Ant/JUnit, BatchTest: ClassNotFound...
Howto run specific JUnit tests in ant?
conditional build failure in Ant
email junit test result
Juint task in Ant