SSM框架单元测试
Posted 324四哥
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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); } } }
以上是关于SSM框架单元测试的主要内容,如果未能解决你的问题,请参考以下文章
SSM整合junit单元测试之org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):(示例代码