加载spring的单元测试

有时候我们需要加载spring的bean进行单元测试,代码如下:

/* 
 * Copyright (c) 2017, S.F. Express Inc. All rights reserved.
 */
package com.sf.ddt.redisUtils;

import java.io.Serializable;

import javax.annotation.Resource;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.sf.framework.cacheproxy.ICache;
import com.sf.framework.cacheproxy.redis.RedisCache;

/**
 * 描述:
 * 
 * 
HISTORY
 * ****************************************************************************
 *  ID   DATE           PERSON          REASON
 *  1    2017年3月23日      835089         Create
 * ****************************************************************************
 * 
* @author 835089 * @since 1.0 */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("/spring/application-common.xml") public class redisUtilTest { @Resource private ICache redisCache; @Test public void setKey(){ System.out.println("ddt common"); //redisCache.set("javaTest", "test java"); Object obj =redisCache.get("javaTest"); System.out.println(obj+""); } }


依赖jar



org.springframework
spring-test
${spring-framework.version}
test





junit
junit
${junit.version}
test

你可能感兴趣的:(spring,java)