码迷,mamicode.com
首页 > 其他好文 > 详细

SSM框架单元测试

时间:2018-05-09 14:54:58      阅读:153      评论:0      收藏:0      [点我收藏+]

标签:init   find   app   public   getbean   private   new   springmvc   ice   

测试方法一

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {
		"classpath:spring/applicationContext-*.xml",
		"classpath:spring/springmvc.xml" })
public class WebMagicTest {

	@Autowired
	private Userservice userservice;

	@Test
	public void findUserTest() throws Exception {
		userservice.findById(1);
	}

}

 测试方法二

public class CommonTest {

	private ApplicationContext applicationContext;

	@Before
	public void setUp() throws Exception {
		applicationContext = new ClassPathXmlApplicationContext(new String[]{"spring/applicationContext-*.xml","spring/springmvc.xml"});
	}

	@Test
	public void testBeans() throws Exception {
		String[] list = applicationContext.getBeanDefinitionNames();
		for (String str : list) {
			System.out.println(str);
		}
	}
}

  

SSM框架单元测试

标签:init   find   app   public   getbean   private   new   springmvc   ice   

原文地址:https://www.cnblogs.com/324sige/p/9013327.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!