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

调试的代码怎么才能不会忘记去掉?

时间:2014-11-18 13:21:24      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   ar   os   sp   strong   

一、添加测试代码

由于诸多原因,软件项目可能会模拟真实环境进行本地单元测试。写一些固定的测试代码,然而这些代码在被部署到服务器上之前一定要去掉的。怎么去掉呢?

1 在myeclipse中可以这样写:

@RequestMapping(value="/do_request",method=RequestMethod.POST)
    public void doRequest(TenpayReqParamBean trpb,HttpServletRequest request,HttpServletResponse response ,PrintWriter out) throws UnsupportedEncodingException{
        createSign( request,response,trpb);
//        response.setContentType("text/html; charset=utf-8");
        response.setContentType("text/plain; charset=utf-8");//TODO 测试 测完可删
        StringBuffer sbHtml = new StringBuffer();

       上面的代码在行尾加了//TODO 描述 ,这样做的好处是方便统一查看,并在部署服务器之前去掉。

二、myeclipse中查看自己添加的 TODO

1.window—show view—Tasks

bubuko.com,布布扣

 

bubuko.com,布布扣

       2 哇!!! 看到了下面这么多TODO,里面很多是代码自动生成的,太多了,怎么区分是我加的测试代码呢?

3 可以  点击Tasks标签右上角的向下箭头--->show—>TODOs查看

bubuko.com,布布扣

       4. 那,现在是不是看起来很清晰了呢?  点击删掉该删掉的代码吧~~

        bubuko.com,布布扣

  希望本文对您开发有帮助~~~ 

调试的代码怎么才能不会忘记去掉?

标签:style   blog   http   io   color   ar   os   sp   strong   

原文地址:http://www.cnblogs.com/qq-757617012/p/4105400.html

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