This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes ANT - JUNIT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "ANT - JUNIT" Watch "ANT - JUNIT" New topic
Author

ANT - JUNIT

Max Hernandez
Greenhorn

Joined: Apr 27, 2011
Posts: 7
HI everyone

im a begginer with ant and junit, this is what is going on I have a AllTest.class locate in C:\hudson\jobs\gsalt\workspace\GSALT\WebContent\WEB-INF\classes under a package name test.com.xxxx.gsalt.business.rules so the complete path is C:\hudson\jobs\gsalt\workspace\GSALT\WebContent\WEB-INF\classes\test\com\xxxx\gsalt\business\rules, I have my build.xml located in C:\hudson\jobs\gsalt\workspace\GSALT\WebContent\WEB-INF\classes (this is just for simple tests) when i run ant i got the following error


C:\hudson\jobs\gsalt>cd C:\hudson\jobs\gsalt\workspace\GSALT\WebContent\WEB-INF\classes

C:\hudson\jobs\gsalt\workspace\GSALT\WebContent\WEB-INF\classes>ant
Buildfile: C:\hudson\jobs\gsalt\workspace\GSALT\WebContent\WEB-INF\classes\build.xml

test:
[junit] Testsuite: test.com.xxxx.gsalt.business.rules.AllTest
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 0 sec
[junit]
[junit] Null Test: Caused an ERROR
[junit] test.com.xxxx.gsalt.business.rules.AllTest
[junit] java.lang.ClassNotFoundException: test.com.xxxx.gsalt.business.rules.AllTest
[junit] at java.net.URLClassLoader$1.run(Unknown Source)
[junit] at java.security.AccessController.doPrivileged(Native Method)
[junit] at java.net.URLClassLoader.findClass(Unknown Source)
[junit] at java.lang.ClassLoader.loadClass(Unknown Source)
[junit] at java.lang.ClassLoader.loadClass(Unknown Source)
[junit] at java.lang.ClassLoader.loadClass(Unknown Source)
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Unknown Source)
[junit]
[junit]
[junit] Test test.com.xxxx.gsalt.business.rules.AllTest FAILED

all:

BUILD SUCCESSFUL
Total time: 0 seconds

C:\hudson\jobs\gsalt\workspace\GSALT\WebContent\WEB-INF\classes>


this is my build.xml

<project default="all">
<property name="tst-dir" location="/hudson/jobs/gsalt/workspace/GSALT/WebContent/WEB-INF/classes" />
<property name="test.class.name" value="test.com.xxxx.gsalt.business.rules.AllTest" />

<path id="classpath.base">
</path>
<path id="classpath.test">
<pathelement location="/hudson/tools/AntTest/lib/junit-4.8.2.jar" />
<pathelement location="${tst-dir}" />
<path refid="classpath.base" />
</path>

<target name="test">
<junit>
<classpath refid="classpath.test" />
<formatter type="brief" usefile="false" />
<test name="${test.class.name}" />
</junit>
</target>

<target name="all" depends="test" />
</project>


does any one know why ant can not find the class?


thanks in advance
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Are you sure your AllTests class has package test.com.xxxx.gsalt.business.rules ?


Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Max Hernandez
Greenhorn

Joined: Apr 27, 2011
Posts: 7
thanks for the fast replay yes I'm sure this is my AllTest.java

----------------------------------------------------------------

package test.com.xxxx.gsalt.business.rules;

import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;


import com.xxxx.ApplicationInitializer;

@RunWith(Suite.class)
@Suite.SuiteClasses({
//Add in here the classes that will b tested example:
test.bis.webframe.business.rules.operation.TestSaveEventLog.class,
test.bis.webframe.gsalt.files.TestGenerateAPFactSheet.class,
test.bis.webframe.gsalt.files.TestGenerateCAWorkSheet.class,
test.com.xxxx.business.rules.dates.TestGetCurrentDate.class,
test.com.xxxx.business.rules.events.TestSaveBusinessObject.class,
test.com.xxxx.business.rules.events.TestDeleteRecords.class,
test.com.xxxx.business.rules.operations.TestSendEmailJNDI.class,
test.com.xxxx.business.rules.operations.TestSendEmailTemplate.class,
test.com.xxxx.business.rules.operations.TestUpdateRecords.class,
test.com.xxxx.gsalt.business.rules.operation.TestRetrieveBlueGroupPersons.class
})

public class AllTests {
public static final String myConfigPath = "C://hudson//jobs//gsalt//workspace//GSALT//WebContent//WEB-INF//config/";
@BeforeClass
public static void setUpBeforeClass() throws Exception {

ApplicationInitializer a = new ApplicationInitializer(myConfigPath,"Business Rules Test","configBRs.xml");
a.initialize();

}

}

-----------------------------------------------------
all the other classes are also located under C:\hudson\jobs\gsalt\workspace\GSALT\WebContent\WEB-INF\classes


any ideas?
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

Max Hernandez wrote:
any ideas?


The only other thing I can see without being on you computer is that I don't see anything in your build.xml to compile the AllTests class.
Max Hernandez
Greenhorn

Joined: Apr 27, 2011
Posts: 7
i have the class already compile in there...but i really apprecite it your help
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ANT - JUNIT