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());
	}
}@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");
	}
}原文:http://blog.csdn.net/h249059945/article/details/47179029