Eclipse + Spring 下 Ant自动化测试

项目使用MyEclipse8.6开发,并且使用的Spring,下面是我的自动化测试脚本,呵呵

 

/**
* 整个测试下BeanFactory只运行一次
* @author Administrator
*
*/
public class BeanFactory {
private static ApplicationContext context ;
static{
context = new ClassPathXmlApplicationContext("applicationContext.xml");
}
private BeanFactory(){

}
public static Object getBean(String beanName){
return context.getBean(beanName);
}
}
  /**
 * 一个简单的测试
 */
public class SeoKeyServiceTest {
	
	static SeoKeyService seoKeyService;
	@BeforeClass
	public static void init(){
		seoKeyService = (SeoKeyService)BeanFactory.getBean("seoKeyService");
	}
	@Test
	public void testBasic(){
		SeoKeyWord skw = new SeoKeyWordTestFactory().getBrandKeyWord();
		skw = seoKeyService.saveSeoKeyWord(skw);
		assertNotNull(skw);
		seoKeyService.deleteSeoKeyWord(skw.getId());
		skw = seoKeyService.getSeoKeyWordById(skw.getId());
		assertTrue(skw == null);
	}
}

下面是我的自动化测试脚本,没有complie过程,使用Eclipse的 Build Automatically

 

<project default="junit"  name="My First Ant project " >
	<description>
		***单元测试
	</description>
	<property name="junit.data" value="report"></property>
	<path id="classpath.main">
		<fileset dir="../s**mmon/lib" includes="**/*.jar" excludes="b*eb/ant.jar"></fileset>
		<fileset dir="D:/javalab/junit" includes="**/*.jar"></fileset>
	</path>
	<target name="init" >
		<delete dir="${junit.data}"></delete>
	</target>
	<target name="junit" depends="init">
		<mkdir dir="${junit.data}"/>
		<junit printsummary="yes" fork="true" haltonfailure="false">
			<classpath>
				<path refid="classpath.main"></path>
				<pathelement location="../s**common/bin"/>
				<pathelement location="WebRoot/WEB-INF/classes"/>
			</classpath>
			<formatter type="xml"/> 
			<batchtest haltonfailure="false"
				todir="${junit.data}">
			 <fileset dir="test" includes="**/*Test.java" >
			 </fileset>
			</batchtest>
		</junit>
	</target>
</project>
 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值