All my JUnit tests fail instantly in my gradle project. It looks like a classpath issue.
My build file is very simple and is as follows: apply plugin:"war" apply plugin:"eclipse" sourceCompatibility = 1.6 targetCompatibility = 1.6 repositories { mavenCentral() mavenRepo urls: "http://fs-mel-nexus:8081/nexus/content/repositories/thirdparty" } dependencies { runtime group: 'org.glassfish.metro', name: 'webservices-rt', version: '2.1.1' providedCompile group: 'org.glassfish', name: 'javax.servlet', version: '3.0' compile project(":dataModelGenerator") runtime group: 'log4j', name: 'log4j', version: '1.2.14' runtime group: 'net.sf.saxon', name: 'saxon', version: '9.1.0.6' runtime group: 'net.sf.saxon', name: 'saxon-xpath', version: '9.1.0.6' runtime group: 'net.sf.saxon', name: 'saxon-dom', version: '9.1.0.6' providedCompile fileTree(webAppDirName+"/WEB-INF/lib").include("**/*.jar") testCompile group: 'junit', name: 'junit', version: '4.8.2' testCompile group: 'xerces', name: 'xercesImpl', version: '2.10.0' } eclipseWtpFacet.whenConfigured { config -> config.facets.each { if (it.name == 'jst.web') { it.version = configurations.providedCompile.getAllDependencies().find{ it.group == 'org.glassfish' && it.name == 'javax.servlet' }.version } } config.facets.unique() } Building the WAR file is fine, but all the JUnit tests fail with the following exception: java.lang.AssertionError: Error message reveived: Could not initialize class au.com.finsyn.acuritywebservices.jobserver.AcurityJob AcurityJob should be one of my classes, so it looks like the built class files are not getting on the classpath when running the unit tests? All of the failed tests have the same Could not initialize class message followed by one of my classes. I've tried a few things playing with the dependencies but nothing to seems to make a difference. Also I can run the unit tests from eclipse using the eclipse projected generated by gradle. The output of the a gradle build: C:\gradleProjects\AcurityWebServices>gradle build :dataModelGenerator:clean :dataModelGenerator:init :dataModelGenerator:compile-field-types-generator :dataModelGenerator:generate-field-types :dataModelGenerator:compile-datamodel-generator :dataModelGenerator:generate-datamodel :dataModelGenerator:compile-datamodel :dataModelGenerator:compileJava :dataModelGenerator:processResources UP-TO-DATE :dataModelGenerator:classes :dataModelGenerator:jar :compileJava Note: C:\gradleProjects\AcurityWebServices\src\main\java\au\com\finsyn\acurity webservices\utils\EPSerializer.j ava uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. :processResources UP-TO-DATE :classes :jar SKIPPED :war :assemble :compileTestJava Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. :processTestResources UP-TO-DATE :testClasses :test Test au.com.finsyn.acuritywebservices.core.DataRecordUtilsTest FAILED Test au.com.finsyn.acuritywebservices.jobserver.AcurityJobTest FAILED Test au.com.finsyn.acuritywebservices.jobserver.JobServerManagerTest FAILED Test au.com.finsyn.acuritywebservices.services.AccountingTest FAILED Test au.com.finsyn.acuritywebservices.services.ClientTest FAILED Test au.com.finsyn.acuritywebservices.services.DoJobTest FAILED Test au.com.finsyn.acuritywebservices.services.EmployerTest FAILED Test au.com.finsyn.acuritywebservices.services.GetFileTest FAILED Test au.com.finsyn.acuritywebservices.services.MemberSupplementaryTest FAILED Test au.com.finsyn.acuritywebservices.services.MemberTest FAILED Test au.com.finsyn.acuritywebservices.services.PublishTest FAILED Test au.com.finsyn.acuritywebservices.services.ReceiptingTest FAILED Test au.com.finsyn.acuritywebservices.services.WebLoginTest FAILED 53 tests completed, 48 failures FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':test'. Cause: There were failing tests. See the report at C:\gradleProjects\AcurityWebServices\build\reports\tests. This email (which includes any attachments) is subject to copyright, confidential and may be privileged. If this email has been sent to you by mistake please inform the sender by reply email and then delete the email, destroy any copy and do not disclose or use the information in it. There is no warranty that this email is error or virus free, and we disclaim all liability for any loss or damage caused by any computer virus or defect. If this is a private communication it does not represent the views of Financial Synergy. Financial Synergy is not liable if an attachment is altered without its written consent.