ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 叶伟平 <>
Subject Ant Junit ignore annotation @ContextConfiguration
Date Tue, 20 Dec 2011 17:17:44 GMT
Hi, everyone!
I have a project which is builded on struts2.2.1, Hibernate3.6.3 and
Spring3.0.5, and I'm running unit tests with Ant. I wrote three

1. TestLoginAction (unit test class)
public class TestLoginAction extends BaseActionTransactionalTest { ... }

2. BaseActionTransactionalTest (common configuration)
	locations = {
public abstract class BaseActionTransactionalTest extends
		StrutsSpringTransactionalTests { ... }

3. StrutsSpringTransactionalTests(transaction control)
@TestExecutionListeners({ TransactionalTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class })
public abstract class StrutsSpringTransactionalTests extends
		StrutsSpringTestCase implements ApplicationContextAware { ... }

It works fine with Eclipse, but when I run TestLoginAction in
Ant-Junit, it fails. The spring configure
files(applicationContext-dao.xml ...) are not loaded. It seem that the
"@ContextConfiguration" annotation is ignored. the build file is like:

         <target name="test" depends="compile.test">
		<mkdir dir="${report.dir}" />
		<property name="tests" value="Test*" />
		<junit printsummary="yes" haltonerror="yes" haltonfailure="yes">
			<formatter type="plain" usefile="false" />
			<formatter type="xml" />
			<batchtest todir="${report.dir}">
				<fileset dir="${src.test.dir}">
					<include name="**/${tests}.java" />
			<classpath refid="lib.test.classpath" />
			<classpath location="${build.home.classes}"/>

	<target name="testrunner" depends="compile.test">
		<java classname="org.junit.runner.JUnitCore" >
			<classpath refid="lib.test.classpath" ></classpath>
			<classpath location="${build.home.classes}"/>
			<arg value="me.yibo.web.action.TestLoginAction"/>

if I run target “testrunner”, it works fine.

Best Regard!

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message