Wednesday, August 15, 2007

Junit test failed in terminal

Use my Eclipse to run junit:
No problem:

Buildfile: /home/ji/projects/springapp/build.xml

build:
[javac] Compiling 1 source file to /home/ji/projects/springapp/war/WEB-INF/classes
clearData:
[echo] CLEAR DATA USING: org.hsqldb.jdbcDriver jdbc:hsqldb:db/test
[sql] Executing commands
[sql] 1 of 1 SQL statements executed successfully
loadData:
[echo] LOAD DATA USING: org.hsqldb.jdbcDriver jdbc:hsqldb:db/test
[sql] Executing commands
[sql] 5 of 5 SQL statements executed successfully
junit:
[junit] Running tests.TestProductManager
[junit] Testsuite: tests.TestProductManager
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.035 sec
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.035 sec
[junit] Running tests.TestProductManagerDaoJdbc
[junit] Testsuite: tests.TestProductManagerDaoJdbc
[junit] 2007-08-15 00:55:31,921 INFO [org.springframework.jdbc.datasource.DriverManagerDataSource] -
[junit] 2007-08-15 00:55:31,922 INFO [db.ProductManagerDaoJdbc] -
[junit] 2007-08-15 00:55:32,387 INFO [db.ProductManagerDaoJdbc] -
[junit] 2007-08-15 00:55:32,403 INFO [db.ProductManagerDaoJdbc] -
[junit] 2007-08-15 00:55:32,403 INFO [db.ProductManagerDaoJdbc] -
[junit] 2007-08-15 00:55:32,406 INFO [org.springframework.jdbc.datasource.DriverManagerDataSource] -
[junit] 2007-08-15 00:55:32,407 INFO [db.ProductManagerDaoJdbc] -
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.771 sec
[junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 0.771 sec
[junit] ------------- Standard Output ---------------
[junit] 2007-08-15 00:55:31,921 INFO [org.springframework.jdbc.datasource.DriverManagerDataSource] -
[junit] 2007-08-15 00:55:31,922 INFO [db.ProductManagerDaoJdbc] -
[junit] 2007-08-15 00:55:32,387 INFO [db.ProductManagerDaoJdbc] -
[junit] 2007-08-15 00:55:32,403 INFO [db.ProductManagerDaoJdbc] -
[junit] 2007-08-15 00:55:32,403 INFO [db.ProductManagerDaoJdbc] -
[junit] 2007-08-15 00:55:32,406 INFO [org.springframework.jdbc.datasource.DriverManagerDataSource] -
[junit] 2007-08-15 00:55:32,407 INFO [db.ProductManagerDaoJdbc] -
[junit] ------------- ---------------- ---------------
[junit] Running tests.TestSpringappController
[junit] Testsuite: tests.TestSpringappController
[junit] 2007-08-15 00:55:32,535 INFO [org.springframework.core.CollectionFactory] -
[junit] 2007-08-15 00:55:32,577 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] -
[junit] 2007-08-15 00:55:32,691 INFO [org.springframework.context.support.FileSystemXmlApplicationContext] -
[junit] 2007-08-15 00:55:32,709 INFO [org.springframework.context.support.FileSystemXmlApplicationContext] - <6 hashcode="6147782]">
[junit] 2007-08-15 00:55:32,719 INFO [org.springframework.context.support.FileSystemXmlApplicationContext] -
[junit] 2007-08-15 00:55:32,722 INFO [org.springframework.context.support.FileSystemXmlApplicationContext] -
[junit] 2007-08-15 00:55:32,725 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] -
[junit] 2007-08-15 00:55:32,802 INFO [web.SpringappController] -
[junit] 2007-08-15 00:55:32,803 INFO [web.SpringappController] -
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.376 sec
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.376 sec
[junit] ------------- Standard Output ---------------
[junit] 2007-08-15 00:55:32,535 INFO [org.springframework.core.CollectionFactory] -
[junit] 2007-08-15 00:55:32,577 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] -
[junit] 2007-08-15 00:55:32,691 INFO [org.springframework.context.support.FileSystemXmlApplicationContext] -
[junit] 2007-08-15 00:55:32,709 INFO [org.springframework.context.support.FileSystemXmlApplicationContext] - <6 hashcode="6147782]">
[junit] 2007-08-15 00:55:32,719 INFO [org.springframework.context.support.FileSystemXmlApplicationContext] -
[junit] 2007-08-15 00:55:32,722 INFO [org.springframework.context.support.FileSystemXmlApplicationContext] -
[junit] 2007-08-15 00:55:32,725 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] -
[junit] 2007-08-15 00:55:32,802 INFO [web.SpringappController] -
[junit] 2007-08-15 00:55:32,803 INFO [web.SpringappController] -
[junit] ------------- ---------------- ---------------
BUILD SUCCESSFUL
Total time: 3 seconds




When I use the terminal command:
ant junit
Error comes out:


Buildfile: build.xml

build:
[javac] Compiling 1 source file to /home/ji/projects/springapp/war/WEB-INF/classes

clearData:
[echo] CLEAR DATA USING: org.hsqldb.jdbcDriver jdbc:hsqldb:db/test
[sql] Executing commands
[sql] 1 of 1 SQL statements executed successfully

loadData:
[echo] LOAD DATA USING: org.hsqldb.jdbcDriver jdbc:hsqldb:db/test
[sql] Executing commands
[sql] 5 of 5 SQL statements executed successfully

junit:

BUILD FAILED
/home/ji/projects/springapp/build.xml:175: java.lang.NoClassDefFoundError: org/apache/tools/ant/types/ResourceCollection



I think the reasons can be they use different junit.jar files, or my Ant did not configure well. Anyway, the springapp website runs without any problem. I install
Apache Ant version 1.6.5 compiled on July 5 2006

No comments: