Eclipse + Spring 上 Ant自动化测试
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>