spring_junit4.4
2011年09月01日
package test; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autow ired; import org.springframework.test.context.ContextConfigurat ion; import org.springframework.test.context.junit4.AbstractTr ansactionalJUnit4SpringContextTests; import org.springframework.test.context.junit4.SpringJUni t4ClassRunner; import com.byd.mmerp.service.impl.T1Service; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"applicationConte xt.xml"}) public class T1ServiceTest extends AbstractTransactionalJUnit4SpringContextTests { @Autowired private T1Service t1Service; @Test public void testGetT1() { String name = t1Service.getT1(1).getName(); System.out.println(name); } }
2011年09月01日
package test; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autow ired; import org.springframework.test.context.ContextConfigurat ion; import org.springframework.test.context.junit4.AbstractTr ansactionalJUnit4SpringContextTests; import org.springframework.test.context.junit4.SpringJUni t4ClassRunner; import com.byd.mmerp.service.impl.T1Service; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations={"applicationConte xt.xml"}) public class T1ServiceTest extends AbstractTransactionalJUnit4SpringContextTests { @Autowired private T1Service t1Service; @Test public void testGetT1() { String name = t1Service.getT1(1).getName(); System.out.println(name); } }
本文展示了如何使用Spring框架与JUnit4进行单元测试,通过实例代码演示了如何配置测试上下文并执行测试方法。
284

被折叠的 条评论
为什么被折叠?



