首页 > 代码库 > SSM 创建一个测试类 Junit Test
SSM 创建一个测试类 Junit Test
package yourMvc;import javax.annotation.Resource;import org.junit.Test;import org.apache.log4j.Logger;import org.junit.runner.RunWith;import org.springframework.test.context.ContextConfiguration;import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;import com.alibaba.fastjson.JSON;import com.maimai.pojo.Student;import com.maimai.service.IStudentService;@RunWith(SpringJUnit4ClassRunner.class) //表示继承了SpringJUnit4ClassRunner类@ContextConfiguration(locations = { "classpath:spring-mybatis.xml" })public class TestStudent { private static Logger logger = Logger.getLogger(TestStudent.class); @Resource private IStudentService studentService = null; @Test public void studentTest() { Student student = studentService.getStudentById(1); logger.info(JSON.toJSONString(student)); }}
run as JUnit Test
结果
[yourMvc.TestStudent] - {"age":24,"id":1,"password":"123456","userName":"麦麦"}
参考博客
http://blog.csdn.net/zhshulin/article/details/37956105#
http://blog.csdn.net/zhshulin/article/details/23912615
待参考博客
http://blog.csdn.net/loginandpwd/article/details/74157210
SSM 创建一个测试类 Junit Test
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。