JUnit tests not running in TeamCity

Hi,

I have a test target inside my ANT build file which TeamCity pick up on, but every time the test run I get this error:

Running Tests.DomainModel.StatisticalDatasetTests
: Testsuite: Tests.DomainModel.StatisticalDatasetTests
: Tests.DomainModel.StatisticalDatasetTests (<1s)
: java.lang.ClassNotFoundException: Tests.DomainModel.StatisticalDatasetTests
:
java.lang.ClassNotFoundException: Tests.DomainModel.StatisticalDatasetTests
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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:336)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:912)
at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:766)

My target name looks like this:

]]>

If I just put <fileset dir="${module.bdsfmcmonitor.basedir}/" includes="*/Test*.class"/> it looks for a class defined as out.production.BDSFMCMonitor.Tests.... and so on and so forth. Could anyone give me some pointers?

Thanks,
Matt

8 comments

Matt,

Does your task run OK without TeamCity?

You probably need a ]]> element to set the classpath for the junit task.

--
Best regards,

Yegor Yarko
Project Manager
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0

This is what I have, do I need something else?

]]>

Matt

0

Matt,

- You have the line commented out in the snippet you posted before.
- Do you include you code that is meant to be tested by the tests in the classpath?

Please make sure your junit task works when invoked manually and only then try adding it into the build run by TeamCity.

--
Best regards,

Yegor Yarko
Project Manager
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0

I uncommented out the classpath element but it didn't fix anything. How and where should I include the Classpath of my classes? Should they be full class names like Package1.Package2.Package3...PackageN.ClassName?

This is the first time I've set up an ANT build, I'm used to NANT so you'll have to bear with me.

Thanks,
Matt

0

Matt,

Running JUnit tests is not a TeamCity-specific task, so you could find the necessary information on lots of resources out there. e.g. browse through the examples here: http://ant.apache.org/manual/OptionalTasks/junit.html

Here is an example of a task that works
classpath's pathelement's location attribute should refer to the directory with compiler output.

]]>
<include name="*/.java"/>
</fileset>
</batchtest>
</junit>

This is used in one of the test builds, so it's specific to its particular usage.

If you still have problems setting JUnit up, I'd recommend going through some JUnit tutorial.

--
Best regards,

Yegor Yarko
Project Manager
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0

Store your Tiffany jewelry in tarnish prevention cloths or bags . The treated cloth slows down the tarnishing process and keeps the tiffany jewelry from rubbing against harder jewelry that can scratch it. Try to to keep your tiffany pendants in a cool, dry place.
Tiffany & Co specialises in quality handcrafted designer siliver jewellery, Tiffany On Sale provides hundreds of discount Tiffany & Co Necklaces, Pendants

0

Very good post would need confirmation on this thanks.

footballshirtshopuk.com

0

Please sign in to leave a comment.