zoukankan      html  css  js  c++  java
  • CodeCover初体验

    国庆刚过完,闲来无事,就随便看看,顺便来了解下一些工具的使用,在工作中要用到的时候可以直接上手。

    CodeCover是一个免费的白盒测试工具,主要测试代码、分支、循环、MC/DC 覆盖。支持为每个测试用例生成独立的报表,目前支持的语言有 Java 和 COBOL。本篇介绍CodeCover作为MyEclipse的插件时的使用。

    官网:http://codecover.org/index.html

    一. 下载安装

    The CodeCover MyEclipse Plugin is installed using the standard Eclipse update mechanism:

    1. Start MyEclipse.
    2. From the main menu, select "Help", "Software updates", "Find and install...".

      

      3. In the upcoming dialog, select "Search for new features to install" and click " "Next".

      

     4. The list containing known update sites will be displayed. Create a new update site by clicking on "New Remote Site..." and enter the following information:

       Name: CodeCover Update Site
       URL:  http://update.codecover.org/
    

    Select the newly created site, if not already selected, and click "Finish". Eclipse will now contact the CodeCover update site; this might take a moment depending on your network connection.

      

     5. In the next dialog, you will see the list of features found on the update site; for now, CodeCover consists of only one feature. Select it for installation and click "Next".

     6. After the download has finished, Eclipse will ask you some questions about the license and installation, and prompt to restart the workbench. You should confirm the restart as not all CodeCover features are guaranteed to work if you simply click "Apply Changes".

      

    Now CodeCover for MyEclipse is installed! You can proceed to the CodeCover Eclipse walkthrough to learn how you can use it.

    二.  使用

     1. Selecting the files to instrument

    Open the Package Explorer view. Choose the Java Classes and Packages you want to instrument and open the context menu by right-clicking on the selected items. The menu item "Use For Coverage Measurement" allows you to toggle the instrumentation state of the selected items.

    选中之后,此类前面就会有一个标记,如下图:

    2.Enabling CodeCover for a Java project

    Open the Properties of your project, e.g. by selecting the project in the Package Explorer and choosing the Properties menu item of the Project menu. Once the Properties are visible, select the CodeCover tab. This tab contains a checkbox which you use to enable/disable CodeCover for the project.

    3.Running a Java project with CodeCover

    Select the CodeCover tab and click on the "Run As"-"CodeCover Measurement " checkbox. Click the Run button to start the application. 

    Once the execution of the application is finished, the gathered coverage data will be shown in the Coverage View.

    4. Test Sessions View

    5. Coverage View

    Last Two View come from Menu(Windows)-Show View-Other:CodeCover

     最后再来工具查看对应的代码:

    讲到这里,CodeCover已讲解完了,对它的基本使用已了解,待日后工作使用到的时候再去详细了解。

  • 相关阅读:
    数据库索引类型及实现方式
    MyBatis从入门到精通(十一):MyBatis高级结果映射之一对多映射
    解决克隆 centos虚拟机后修改克隆后的机器的ip、mac、uuid失败的问题
    多层表达式
    条件过滤
    复杂表达式
    生成列表
    迭代dict的key和value
    迭代dict的value
    索引迭代
  • 原文地址:https://www.cnblogs.com/yangxia-test/p/4013494.html
Copyright © 2011-2022 走看看