• 热门专题

Web单元测试常用工具介绍

作者:  发布日期:2015-08-02 21:57:04
Tag标签:常用工具  单元  
  • 1 使用testng框架进行web的单元测试,不用每次都启动tomcat

     

    @ContextConfiguration(locations={"application-context.xml"})
    @TransactionConfiguration(defaultRollback = true)
    public class TestSafety extends AbstractTestNGSpringContextTests {
    	
    	@Autowired
    	SafetyStockJob safetyStockJob;
    	
    	@Test
    	public void test1(){
    		List<String> list=safetyStockJob.getFH_date();
    		System.out.println(1234);
    		System.out.println(list.toString());
    		System.out.println(list.size());
    	}
    }

    2 使用spring提供的单元测试插件

     

     

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration({ "classpath:applicationContext.xml" })
    public class SSHTest {
    
    	@Resource
    	private SysUserDao sysUserDao;
    
    	@Resource
    	private SysUserService sysUserService;
    
    	@Before
    	public void setUp() throws Exception {
    
    	}
    
    	@Test
    	public final void testSave() {
    		// System.out.println("sysUserService:::" + sysUserService);
    		SysUser sysUser = sysUserService.getByProerties("userName", "admin");
    	}
    
    }


     

About IT165 - 广告服务 - 隐私声明 - 版权申明 - 免责条款 - 网站地图 - 网友投稿 - 联系方式
本站内容来自于互联网,仅供用于网络技术学习,学习中请遵循相关法律法规