spring+junit单元测试

<1>读取文件:

配置文件在classes下:locations = {"classpath*:/spring/applicationContext.xml"}

配置文件在web-inf下:locations = {"file:web/WEB-INF/applicationContext.xml"}

<2>实例类:

package com.test;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.entity.User;
import com.service.impl.UserService;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"file:web/WEB-INF/applicationContext.xml"})
public class PageTest {

@Autowired
private UserService userService;

@Test
public void testPage(){
  //  add your  test  code
}
}

}

上一篇:vs2010配置boost编程环境(照抄并简化)


下一篇:[游戏学习29] Win32 图像处理1