首页 > 其他 > 详细

SSM 创建一个测试类 Junit Test

时间:2017-07-09 20:32:57      阅读:533      评论:0      收藏:0      [点我收藏+]
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

原文:http://www.cnblogs.com/baicaocanhua/p/7142502.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!