SSM框架单元测试


测试方法一

@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);
		}
	}
}

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM